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).
  
  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).
  
  Reviewed by:  andrew
  Approved by:  re (gjb)
  Sponsored by: DARPA, AFRL
  Differential Revision:        https://reviews.freebsd.org/D6815

Added:
  head/lib/libc/sys/pipe.c   (contents, props changed)
Deleted:
  head/lib/libc/aarch64/sys/pipe.S
  head/lib/libc/amd64/sys/pipe.S
  head/lib/libc/arm/sys/pipe.S
  head/lib/libc/i386/sys/pipe.S
  head/lib/libc/mips/sys/pipe.S
  head/lib/libc/powerpc/sys/pipe.S
  head/lib/libc/powerpc64/sys/pipe.S
  head/lib/libc/riscv/sys/pipe.S
  head/lib/libc/sparc64/sys/pipe.S
Modified:
  head/lib/libc/aarch64/sys/Makefile.inc
  head/lib/libc/amd64/sys/Makefile.inc
  head/lib/libc/arm/sys/Makefile.inc
  head/lib/libc/i386/sys/Makefile.inc
  head/lib/libc/mips/sys/Makefile.inc
  head/lib/libc/powerpc/sys/Makefile.inc
  head/lib/libc/powerpc64/sys/Makefile.inc
  head/lib/libc/riscv/sys/Makefile.inc
  head/lib/libc/sparc64/sys/Makefile.inc
  head/lib/libc/sys/Makefile.inc
  head/lib/libc/sys/pipe.2

Modified: head/lib/libc/aarch64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/aarch64/sys/Makefile.inc      Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/aarch64/sys/Makefile.inc      Wed Jun 22 21:11:27 2016        
(r302092)
@@ -6,7 +6,6 @@ SRCS+=  __vdso_gettc.c
 
 #MDASM= ptrace.S
 MDASM= cerror.S \
-       pipe.S \
        shmat.S \
        sigreturn.S \
        syscall.S \

Modified: head/lib/libc/amd64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/amd64/sys/Makefile.inc        Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/amd64/sys/Makefile.inc        Wed Jun 22 21:11:27 2016        
(r302092)
@@ -4,7 +4,7 @@
 SRCS+= amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c \
        amd64_set_gsbase.c __vdso_gettc.c
 
-MDASM= vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
+MDASM= vfork.S brk.S cerror.S exect.S getcontext.S ptrace.S \
        sbrk.S setlogin.S sigreturn.S
 
 # Don't generate default code for these syscalls:

Modified: head/lib/libc/arm/sys/Makefile.inc
==============================================================================
--- head/lib/libc/arm/sys/Makefile.inc  Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/arm/sys/Makefile.inc  Wed Jun 22 21:11:27 2016        
(r302092)
@@ -2,7 +2,7 @@
 
 SRCS+= __vdso_gettc.c
 
-MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S 
syscall.S
+MDASM= Ovfork.S brk.S cerror.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:
 NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o

Modified: head/lib/libc/i386/sys/Makefile.inc
==============================================================================
--- head/lib/libc/i386/sys/Makefile.inc Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/i386/sys/Makefile.inc Wed Jun 22 21:11:27 2016        
(r302092)
@@ -8,7 +8,7 @@ SRCS+=  i386_get_fsbase.c i386_get_gsbase
        i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \
        __vdso_gettc.c
 
-MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
+MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S ptrace.S \
        sbrk.S setlogin.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:

Modified: head/lib/libc/mips/sys/Makefile.inc
==============================================================================
--- head/lib/libc/mips/sys/Makefile.inc Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/mips/sys/Makefile.inc Wed Jun 22 21:11:27 2016        
(r302092)
@@ -3,7 +3,7 @@
 SRCS+= trivial-vdso_tc.c
 
 MDASM=  Ovfork.S brk.S cerror.S exect.S \
-       pipe.S ptrace.S sbrk.S syscall.S
+       ptrace.S sbrk.S syscall.S
 
 # Don't generate default code for these syscalls:
 NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o

Modified: head/lib/libc/powerpc/sys/Makefile.inc
==============================================================================
--- head/lib/libc/powerpc/sys/Makefile.inc      Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/powerpc/sys/Makefile.inc      Wed Jun 22 21:11:27 2016        
(r302092)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-MDASM+=        brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S
+MDASM+=        brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S
 
 # Don't generate default code for these syscalls:
 NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o

Modified: head/lib/libc/powerpc64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/powerpc64/sys/Makefile.inc    Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/powerpc64/sys/Makefile.inc    Wed Jun 22 21:11:27 2016        
(r302092)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-MDASM+=        brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S
+MDASM+=        brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S
 
 # Don't generate default code for these syscalls:
 NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o

Modified: head/lib/libc/riscv/sys/Makefile.inc
==============================================================================
--- head/lib/libc/riscv/sys/Makefile.inc        Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/riscv/sys/Makefile.inc        Wed Jun 22 21:11:27 2016        
(r302092)
@@ -4,7 +4,6 @@ SRCS+=  trivial-vdso_tc.c
 
 #MDASM= ptrace.S
 MDASM= cerror.S \
-       pipe.S \
        shmat.S \
        sigreturn.S \
        syscall.S \

Modified: head/lib/libc/sparc64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/sparc64/sys/Makefile.inc      Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/sparc64/sys/Makefile.inc      Wed Jun 22 21:11:27 2016        
(r302092)
@@ -12,7 +12,7 @@ SRCS+=        __sparc_sigtramp_setup.c \
 
 CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu
 
-MDASM+=        brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S 
sigaction1.S
+MDASM+=        brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S sigaction1.S
 
 # Don't generate default code for these syscalls:
 NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o

Modified: head/lib/libc/sys/Makefile.inc
==============================================================================
--- head/lib/libc/sys/Makefile.inc      Wed Jun 22 21:00:28 2016        
(r302091)
+++ head/lib/libc/sys/Makefile.inc      Wed Jun 22 21:11:27 2016        
(r302092)
@@ -28,6 +28,8 @@ SRCS+= futimens.c utimensat.c
 NOASM+= futimens.o utimensat.o
 PSEUDO+= _futimens.o _utimensat.o
 
+SRCS+= pipe.c
+
 INTERPOSED = \
        accept \
        accept4 \

Modified: head/lib/libc/sys/pipe.2
==============================================================================
--- head/lib/libc/sys/pipe.2    Wed Jun 22 21:00:28 2016        (r302091)
+++ head/lib/libc/sys/pipe.2    Wed Jun 22 21:11:27 2016        (r302092)
@@ -28,7 +28,7 @@
 .\"     @(#)pipe.2     8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd May 1, 2013
+.Dd June 22, 2016
 .Dt PIPE 2
 .Os
 .Sh NAME
@@ -118,6 +118,9 @@ and
 .Fn pipe2
 system calls will fail if:
 .Bl -tag -width Er
+.It Bq Er EFAULT
+.Ar fildes
+argument points to an invalid memory location.
 .It Bq Er EMFILE
 Too many descriptors are active.
 .It Bq Er ENFILE

Added: head/lib/libc/sys/pipe.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/sys/pipe.c    Wed Jun 22 21:11:27 2016        (r302092)
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2016 SRI International
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/cdefs.h>
+
+#include <unistd.h>
+
+__weak_reference(__sys_pipe, pipe);
+__weak_reference(__sys_pipe, _pipe);
+
+extern int __sys_pipe2(int fildes[2], int flags);
+
+int
+__sys_pipe(int fildes[2])
+{
+
+       return (__sys_pipe2(fildes, 0));
+}
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to