Not properly reporting this error can result in values "returned" from
sbytes being misinterpreted by the caller.
MFC after: 2 weeks
Sponsored by: Netflix, Inc
Differential D18623
Address the fact that errors from `copyout(9)` are not properly percolated up on failure ngie on Dec 20 2018, 7:43 PM. Authored by Tags None Referenced Files
Details Not properly reporting this error can result in values "returned" from MFC after: 2 weeks I ran the sendfile testcases in https://github.com/freebsd/freebsd/pull/243 successfully $ kyua test -k /usr/tests/lib/libc/sys/Kyuafile sendfile_test
Diff Detail
Event Timeline
Comment Actions
Comment Actions *sigh* ... reading the contract again: what about EIO, ENOBUFS, and EPIPE? I'm making this more complicated than it needs to be. I should just return the error (if there is one) or the copyout error if there was one (squashing the other error, if there was one, because EFAULT is a pretty rare error to run into with a user buffer).
Comment Actions After speaking with @markj on IRC, I think the best move forward is to restructure/change the sendfile(2) API to match Linux's a bit more, i.e.,
Comment Actions To be clear, this approach induces a certain amount of pain, and it should not be undertaken unless the benefits are worth it. Some justification based on actual users of sendfile() is needed. If it's not worth it, then this problem is just a wart.
Comment Actions
I agree with Mark. Usually if copyout fails it means that calling process is in such a bad state, that failed sendfile is a lesser problem. Comment Actions
No, this isn't going to work. Changing 20 year old API due to theoretical error. Let me remind that no one observed it in the wild. I'd suggest the following. Add a note in the sendfile.2 manual page that this problem is potentially possible. Paranoid users of the API are advised to initialize sbytes to bogus value (e.g. -1) prior to syscall and after successful syscall (retval is 0 or EAGAIN) check if value changed at all. |