Page MenuHomeFreeBSD

vmapbuf: don't smuggle user address via b_data
ClosedPublic

Authored by brooks on Oct 14 2020, 11:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 12:02 PM
Unknown Object (File)
Feb 1 2024, 1:38 PM
Unknown Object (File)
Jan 13 2024, 2:48 AM
Unknown Object (File)
Dec 20 2023, 6:55 AM
Unknown Object (File)
Dec 11 2023, 5:42 PM
Unknown Object (File)
Dec 3 2023, 4:43 PM
Unknown Object (File)
Dec 3 2023, 4:43 PM
Unknown Object (File)
Nov 16 2023, 11:43 AM
Subscribers

Details

Summary

Instead, add a uaddr argument to vmapbuf. Since this argument is
always a pointer use a type of void * and cast to vm_offset_t in
vmapbuf. (In CheriBSD we've altered vm_fault_quick_hold_pages to
take a pointer and check its bounds.)

In no other situtation does b_data contain a user pointer and vmapbuf
replaces b_data with the actual mapping.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34172
Build 31325: arc lint + arc unit

Event Timeline

I know I didn't say this earlier in CheriBSD, but looking at the patch again, I think it might be cleaner to pass in the size explicitly as well and have vmapbuf set bp->bufsize rather than than smuggling that in as well. Together, b_data, b_offset, and b_bufsize describe the memory buffer, and passing in the length would let vmapbuf be responsible for setting all of those.

sys/ufs/ffs/ffs_rawread.c
250

Unrelated bug: vmapbuf() overwrites bp->b_offset. This should only be setting bp->b_iooffset.

  • Pass size rather than smuggling via b_bufsize.

Thanks.

sys/kern/vfs_bio.c
4915

This check is now dead code that can be removed I think since size_t is unsigned?

This revision is now accepted and ready to land.Oct 19 2020, 8:25 PM
This revision now requires review to proceed.Oct 19 2020, 9:06 PM

This is good... only caveat is that MFC code near this stuff might be a pain... A minor inconvenience at best, so this is a LGTM!

This revision is now accepted and ready to land.Oct 19 2020, 11:26 PM
This revision was automatically updated to reflect the committed changes.