Page MenuHomeFreeBSD

Fix a call to copyout() so that it checks for an error return
ClosedPublic

Authored by rmacklem on Dec 21 2023, 8:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 23 2024, 12:37 AM
Unknown Object (File)
Mar 2 2024, 1:09 AM
Unknown Object (File)
Feb 16 2024, 5:38 AM
Unknown Object (File)
Jan 14 2024, 7:07 AM
Unknown Object (File)
Dec 25 2023, 5:12 PM
Unknown Object (File)
Dec 22 2023, 11:04 PM
Subscribers

Details

Summary

If vfs.nfs.nfs_directio_enable is set non-zero (the default is
zero) and a file on an NFS mount is read after being opened
with O_DIRECT | O_ RDONLY, a call to nfsm_mbufuio() calls
copyout() without checking for an error return.
If copyout() returns EFAULT, this would not work correctly.

Only the call path VOP_READ()->ncl_readrpc()->nfsrpc_read()->nfsrpc_readrpc()
will do this and the error return for EFAULT will be returned back to VOP_READ().

This patch adds the error check to nfsm_mbufuio().

Test Plan

Hacked the code to artificially make nfsm_mbufuio() return
EFAULT instead of doing the copyout() call intermittently
and then did a O_DIRECT | O_RDONLY read of a fair sized
file with vfs.nfs.nfs_directio_enable set to 1.

This worked correctly, so any return of EFAULT by
copyout() should behave correctly as well.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable