Page MenuHomeFreeBSD

sendfile(2): rework compat implementation
Needs ReviewPublic

Authored by brooks on Thu, Aug 20, 9:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 20, 1:21 PM
Unknown Object (File)
Thu, Aug 20, 1:21 PM
Unknown Object (File)
Thu, Aug 20, 12:56 PM
Unknown Object (File)
Thu, Aug 20, 12:51 PM
Subscribers

Details

Reviewers
kib
jhb
glebius
markj
Group Reviewers
cheri
Summary

Rename the sendfile() function to kern_sendfile() and extend it with two
function pointer arguments to copy in the header/trailer structure and
the create uio's for the header and trailer as required. Use this
to allow the removal of freebsd32_do_sendfile() which was a nearly
idential duplicate of sendfile() with attendant synchronization cost.

In the process, restyle calls to kern_sendfile to use compound literals.

Effort: CHERI upstreaming
Sponsored by: Innovate UK

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 75779
Build 72662: arc lint + arc unit

Event Timeline

Merging the implementations will avoid future instances of oversights like the one fixed in 4b17776d9afd0009ac8547126c59c97eda0f3fc9 as well as avoiding a third copy of this code from freebsd64 when it lands.

sys/compat/freebsd32/freebsd32_misc.c
2201

Should the first parameter just be const void *? Otherwise it looks like we're calling this function via an incompatible function pointer. I'm not sure if that's UB.

2213
sys/kern/kern_sendfile.c
1250

Can we handle this in a COMPAT_FREEBSD4-specific copyinuio callback? That seems cleaner, and then you can drop the compat flag.

Why passing struct sendile_args to kern_sendfile()? This is not how all other kern_* wrappers are done, and IMO is worse than flattening the args. You have to explicitly initialize the literal anyway, which makes it equivalent to list the function's argument in the call.