Page MenuHomeFreeBSD

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

Authored by jhb on Mar 13 2026, 1:44 PM.
Tags
None
Referenced Files
F161885413: D55845.diff
Tue, Jul 7, 5:29 PM
Unknown Object (File)
Sun, Jul 5, 9:11 PM
Unknown Object (File)
Sat, Jul 4, 3:47 PM
Unknown Object (File)
Mon, Jun 29, 1:38 AM
Unknown Object (File)
Fri, Jun 26, 5:09 AM
Unknown Object (File)
Fri, Jun 26, 5:09 AM
Unknown Object (File)
Sun, Jun 21, 8:48 PM
Unknown Object (File)
Sat, Jun 13, 11:01 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.Mar 13 2026, 1:44 PM
This revision is now accepted and ready to land.Mar 13 2026, 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.