svn commit: r302092 - in head/lib/libc: aarch64/sys amd64/sys arm/sys i386/sys mips/sys powerpc/sys powerpc64/sys riscv/sys sparc64/sys sys

Jilles Tjoelker jilles at stack.nl
Thu Jun 23 21:34:13 UTC 2016


On Wed, Jun 22, 2016 at 09:11:27PM +0000, Brooks Davis wrote:
> Author: brooks
> Date: Wed Jun 22 21:11:27 2016
> New Revision: 302092
> URL: https://svnweb.freebsd.org/changeset/base/302092

> Log:
>   Replace use of the pipe(2) system call with pipe2(2) with a zero flags
>   value.

>   This eliminates the need for machine dependant assembly wrappers for
>   pipe(2).

I like it.

>   It also make passing an invalid address to pipe(2) return EFAULT rather
>   than triggering a segfault.  Document this behavior (which was already
>   true for pipe2(2), but undocumented).

It is valid to promise [EFAULT] in this specific case since the kernel
undoes the call's effects when the copyout fails (by closing the
descriptors) and it seems unlikely that we will need a userland wrapper
around pipe() or pipe2() that needs to access the created file
descriptors. However, POSIX does not require it: passing invalid
pointers to functions specified by the standard is undefined behaviour.

See r241001 for some man pages where I removed the [EFAULT] condition
because it is wrong for both reasons mentioned above (something changes
even after copyout failure and userland wrappers dereference pointers).

-- 
Jilles Tjoelker


More information about the svn-src-all mailing list