Page MenuHomeFreeBSD

LinuxKPI: Better handling of zero-size and off-the-end reads
ClosedPublic

Authored by jhb on Fri, Mar 13, 1:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 5, 6:10 PM
Unknown Object (File)
Sun, Apr 5, 2:24 PM
Unknown Object (File)
Sun, Apr 5, 9:08 AM
Unknown Object (File)
Sat, Apr 4, 3:30 AM
Unknown Object (File)
Tue, Mar 24, 7:26 PM
Unknown Object (File)
Tue, Mar 24, 11:25 AM
Unknown Object (File)
Sun, Mar 22, 6:53 PM
Unknown Object (File)
Sun, Mar 22, 3:05 AM
Subscribers

Details

Summary

I noticed that the buf_size < 0 check can never be true (it's a
size_t) and decided to check for this condition by an alternate
expression, and I also noticed that a read_size of 0 would incorrectly
return -EFAULT. Instead, return success for both of these cases as
reading beyond the EOF of a normal file also returns EOF, not EINVAL.

Sponsored by: AFRL, DARPA

Diff Detail

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

Event Timeline

jhb requested review of this revision.Fri, Mar 13, 1:44 PM
This revision is now accepted and ready to land.Fri, Mar 13, 2:11 PM

I probably could rearrange this to merge it before the change to switch to user pointers.

Though the EFAULT error is only after reverting the memcpy back to copy_from_user.