diff options
author | Renato Botelho <renato@netgate.com> | 2016-09-12 14:46:47 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-09-12 14:46:47 -0300 |
commit | 710146e9ac46d798c3f15a8830f48e94bad137a5 (patch) | |
tree | cbebe7a1c7a2faa1c2c3936972eca1134635b2b9 /lib/libc | |
parent | 39fd693a18f8ef73b1268f2321393d5ca6101e89 (diff) | |
parent | 5986af9d01080d549cde638c5af2bef5fd977207 (diff) | |
download | FreeBSD-src-710146e9ac46d798c3f15a8830f48e94bad137a5.zip FreeBSD-src-710146e9ac46d798c3f15a8830f48e94bad137a5.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'lib/libc')
30 files changed, 212 insertions, 541 deletions
diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc index 32986c9fa..9e0a217 100644 --- a/lib/libc/amd64/sys/Makefile.inc +++ b/lib/libc/amd64/sys/Makefile.inc @@ -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 pipe.S \ sbrk.S setlogin.S sigreturn.S # Don't generate default code for these syscalls: diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S deleted file mode 100644 index 9c4628d..0000000 --- a/lib/libc/amd64/sys/ptrace.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)ptrace.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax -#ifdef PIC - movq PIC_GOT(CNAME(errno)),%r8 - movl %eax,(%r8) -#else - movl %eax,CNAME(errno)(%rip) -#endif - mov $SYS_ptrace,%eax - KERNCALL - jb HIDENAME(cerror) - ret -END(ptrace) - - .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc index fd251c8..9d47547 100644 --- a/lib/libc/arm/sys/Makefile.inc +++ b/lib/libc/arm/sys/Makefile.inc @@ -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 pipe.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 diff --git a/lib/libc/arm/sys/ptrace.S b/lib/libc/arm/sys/ptrace.S deleted file mode 100644 index 876da32..0000000 --- a/lib/libc/arm/sys/ptrace.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.7 2003/08/07 16:42:04 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 - */ - -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); -#include "SYS.h" - -ENTRY(ptrace) - stmfd sp!, {r0-r3, lr} - sub sp, sp, #4 /* align stack */ - bl PIC_SYM(_C_LABEL(__error), PLT) - add sp, sp, #4 /* unalign stack */ - mov r1, #0x00000000 - str r1, [r0] - ldmfd sp!, {r0-r3, lr} - SYSTRAP(ptrace) - bcs PIC_SYM(CERROR, PLT) - RET -END(ptrace) diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 index f0d0f4b..b732863 100644 --- a/lib/libc/gen/directory.3 +++ b/lib/libc/gen/directory.3 @@ -28,7 +28,7 @@ .\" @(#)directory.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd May 6, 2015 +.Dd August 31, 2016 .Dt DIRECTORY 3 .Os .Sh NAME @@ -69,6 +69,15 @@ .Ft int .Fn dirfd "DIR *dirp" .Sh DESCRIPTION +.Bf -symbolic +The +.Fn readdir_r +interface is deprecated +because it cannot be used correctly unless +.Brq Va NAME_MAX +is a fixed value. +.Ef +.Pp The .Fn opendir function @@ -123,7 +132,13 @@ The .Fn readdir function returns a pointer to the next directory entry. -It returns +The directory entry remains valid until the next call to +.Fn readdir +or +.Fn closedir +on the same +.Em directory stream . +The function returns .Dv NULL upon reaching the end of the directory or on error. In the event of an error, @@ -140,6 +155,13 @@ provides the same functionality as but the caller must provide a directory .Fa entry buffer to store the results in. +The buffer must be large enough for a +.Vt struct dirent +with a +.Va d_name +array with +.Brq Va NAME_MAX ++ 1 elements. If the read succeeds, .Fa result is pointed at the diff --git a/lib/libc/gen/getvfsbyname.3 b/lib/libc/gen/getvfsbyname.3 index f2a5965..a0fc843 100644 --- a/lib/libc/gen/getvfsbyname.3 +++ b/lib/libc/gen/getvfsbyname.3 @@ -28,7 +28,7 @@ .\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd April 5, 2007 +.Dd August 30, 2016 .Dt GETVFSBYNAME 3 .Os .Sh NAME @@ -97,11 +97,6 @@ sysctl is set to .Sh ERRORS The following errors may be reported: .Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa vfc -argument -points to an invalid address. .It Bq Er ENOENT The .Fa name diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc index ce1fed5..1149526 100644 --- a/lib/libc/i386/sys/Makefile.inc +++ b/lib/libc/i386/sys/Makefile.inc @@ -8,7 +8,7 @@ SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \ 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 pipe.S \ sbrk.S setlogin.S sigreturn.S syscall.S # Don't generate default code for these syscalls: diff --git a/lib/libc/i386/sys/ptrace.S b/lib/libc/i386/sys/ptrace.S deleted file mode 100644 index e4bdf7c..0000000 --- a/lib/libc/i386/sys/ptrace.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)ptrace.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax -#ifdef PIC - PIC_PROLOGUE - movl PIC_GOT(CNAME(errno)),%edx - movl %eax,(%edx) - PIC_EPILOGUE -#else - movl %eax,CNAME(errno) -#endif - mov $SYS_ptrace,%eax - KERNCALL - jb HIDENAME(cerror) - ret -END(ptrace) - - .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/ia64/sys/Makefile.inc b/lib/libc/ia64/sys/Makefile.inc index 2846590..ae75ee0 100644 --- a/lib/libc/ia64/sys/Makefile.inc +++ b/lib/libc/ia64/sys/Makefile.inc @@ -2,7 +2,7 @@ SRCS+= __vdso_gettc.c -MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S ptrace.S \ +MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S \ sbrk.S setlogin.S sigreturn.S swapcontext.S # Don't generate default code for these syscalls: diff --git a/lib/libc/ia64/sys/ptrace.S b/lib/libc/ia64/sys/ptrace.S deleted file mode 100644 index b6d3abd..0000000 --- a/lib/libc/ia64/sys/ptrace.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.4 1996/11/08 00:51:24 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(ptrace, 4) - add r14=@ltoff(errno),gp ;; - ld8 r14=[r14] ;; - st4 [r14]=r0 - CALLSYS_ERROR(ptrace) - br.ret.sptk.few rp -END(ptrace) diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index c219f55..b6a6ff7 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -339,6 +339,7 @@ int __sys_openat(int, const char *, int, ...); int __sys_pselect(int, struct fd_set *, struct fd_set *, struct fd_set *, const struct timespec *, const __sigset_t *); +int __sys_ptrace(int, __pid_t, char *, int); int __sys_poll(struct pollfd *, unsigned, int); int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *, const __sigset_t *); diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc index fc11349..380825a 100644 --- a/lib/libc/mips/sys/Makefile.inc +++ b/lib/libc/mips/sys/Makefile.inc @@ -3,7 +3,7 @@ SRCS+= __vdso_gettc.c MDASM= Ovfork.S brk.S cerror.S exect.S \ - fork.S pipe.S ptrace.S sbrk.S syscall.S + fork.S pipe.S sbrk.S syscall.S # Don't generate default code for these syscalls: NOASM= break.o exit.o ftruncate.o getlogin.o lseek.o mmap.o \ diff --git a/lib/libc/mips/sys/ptrace.S b/lib/libc/mips/sys/ptrace.S deleted file mode 100644 index 8cf984a9..0000000 --- a/lib/libc/mips/sys/ptrace.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.9 2003/08/07 16:42:17 agc Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)ptrace.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$NetBSD: ptrace.S,v 1.9 2003/08/07 16:42:17 agc Exp $") -#endif /* LIBC_SCCS and not lint */ - -NESTED_NOPROFILE(ptrace, CALLFRAME_SIZ, ra) - .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) - SETUP_GP - PTR_SUBU sp, sp, CALLFRAME_SIZ - SETUP_GP64(CALLFRAME_GP, ptrace) - SAVE_GP(CALLFRAME_GP) - - PTR_S ra, CALLFRAME_RA(sp) - - PTR_LA t9, _C_LABEL(__error) # locate address of errno - jalr t9 - - PTR_L ra, CALLFRAME_RA(sp) - INT_S zero, 0(v0) # update errno value - - li v0, SYS_ptrace - syscall - - # Load __cerror's address using our gp, then restore it. - PTR_LA t9, __cerror - RESTORE_GP64 - PTR_ADDU sp, sp, CALLFRAME_SIZ - - bne a3, zero, 1f - - j ra -1: j t9 -END(ptrace) diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index c5bfc5e..ec22570 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -931,7 +931,7 @@ matchlen(struct sockaddr *src, struct sockaddr *dst) while (s < lim) if ((r = (*d++ ^ *s++)) != 0) { - while (r < addrlen * 8) { + while ((r & 0x80) == 0) { match++; r <<= 1; } diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index ebae9d3..38986fc 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -186,6 +186,7 @@ struct hp_order { #define aio_sa aio_un.aiou_sa int aio_matchlen; char *aio_h_addr; + int aio_initial_sequence; }; static struct hostent *_hpcopy(struct hostent *, int *); @@ -711,6 +712,7 @@ _hpreorder(struct hostent *hp) aio[i].aio_dstscope = gai_addr2scopetype(sa); aio[i].aio_dstpolicy = match_addrselectpolicy(sa, &policyhead); set_source(&aio[i], &policyhead); + aio[i].aio_initial_sequence = i; } /* perform sorting. */ @@ -928,7 +930,7 @@ matchlen(struct sockaddr *src, struct sockaddr *dst) while (s < lim) if ((r = (*d++ ^ *s++)) != 0) { - while (r < addrlen * 8) { + while ((r & 0x80) == 0) { match++; r <<= 1; } @@ -1045,6 +1047,23 @@ comp_dst(const void *arg1, const void *arg2) } /* Rule 10: Otherwise, leave the order unchanged. */ + + /* + * Note that qsort is unstable; so, we can't return zero and + * expect the order to be unchanged. + * That also means we can't depend on the current position of + * dst2 being after dst1. We must enforce the initial order + * with an explicit compare on the original position. + * The qsort specification requires that "When the same objects + * (consisting of width bytes, irrespective of their current + * positions in the array) are passed more than once to the + * comparison function, the results shall be consistent with one + * another." + * In other words, If A < B, then we must also return B > A. + */ + if (dst2->aio_initial_sequence < dst1->aio_initial_sequence) + return(1); + return(-1); } diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc index 5193cc2..f590c76 100644 --- a/lib/libc/powerpc/sys/Makefile.inc +++ b/lib/libc/powerpc/sys/Makefile.inc @@ -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 pipe.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 diff --git a/lib/libc/powerpc/sys/ptrace.S b/lib/libc/powerpc/sys/ptrace.S deleted file mode 100644 index 0bc25c9..0000000 --- a/lib/libc/powerpc/sys/ptrace.S +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2002 Peter Grehan. - * All rights reserved. - * - * 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. - */ -/* $NetBSD: ptrace.S,v 1.3 2000/02/23 20:16:57 kleink Exp $ */ - -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(ptrace) - mflr %r0 - stwu %r1,-32(%r1) - stw %r0,36(%r1) - stw %r3,8(%r1) - stw %r4,12(%r1) - stw %r5,16(%r1) - stw %r6,20(%r1) - - bl PIC_PLT(CNAME(__error)) - li %r7,0 - stw %r7,0(%r3) - - lwz %r3,8(%r1) - lwz %r4,12(%r1) - lwz %r5,16(%r1) - lwz %r0,36(%r1) - lwz %r6,20(%r1) - mtlr %r0 - la %r1,32(%r1) - li %r0,SYS_ptrace - sc - bso 1f - blr -1: - b PIC_PLT(HIDENAME(cerror)) - - .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/Makefile.inc b/lib/libc/powerpc64/sys/Makefile.inc index 5193cc2..f590c76 100644 --- a/lib/libc/powerpc64/sys/Makefile.inc +++ b/lib/libc/powerpc64/sys/Makefile.inc @@ -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 pipe.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 diff --git a/lib/libc/powerpc64/sys/ptrace.S b/lib/libc/powerpc64/sys/ptrace.S deleted file mode 100644 index ede00e7..0000000 --- a/lib/libc/powerpc64/sys/ptrace.S +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2002 Peter Grehan. - * All rights reserved. - * - * 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. - */ -/* $NetBSD: ptrace.S,v 1.3 2000/02/23 20:16:57 kleink Exp $ */ - -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(ptrace) - mflr %r0 - std %r0,16(%r1) - stdu %r1,-80(%r1) - stw %r3,48(%r1) - stw %r4,52(%r1) - std %r5,56(%r1) - stw %r6,64(%r1) - - bl CNAME(__error) - nop - li %r7,0 - stw %r7,0(%r3) - - lwz %r3,48(%r1) - lwz %r4,52(%r1) - ld %r5,56(%r1) - lwz %r6,64(%r1) - ld %r1,0(%r1) - ld %r0,16(%r1) - mtlr %r0 - li %r0,SYS_ptrace - sc - bso 1f - blr -1: - stdu %r1,-48(%r1) /* lr already saved */ - bl HIDENAME(cerror) - nop - ld %r1,0(%r1) - ld %r0,16(%r1) - mtlr %r0 - blr - - .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index 304f90a..6ce99d3 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -740,7 +740,7 @@ svc_vc_rendezvous_ops(xprt) ops.xp_reply = (bool_t (*)(SVCXPRT *, struct rpc_msg *))abort; ops.xp_freeargs = - (bool_t (*)(SVCXPRT *, xdrproc_t, void *))abort, + (bool_t (*)(SVCXPRT *, xdrproc_t, void *))abort; ops.xp_destroy = svc_vc_destroy; ops2.xp_control = svc_vc_rendezvous_control; } diff --git a/lib/libc/sparc64/sys/Makefile.inc b/lib/libc/sparc64/sys/Makefile.inc index d1b4b2d..9678c2e 100644 --- a/lib/libc/sparc64/sys/Makefile.inc +++ b/lib/libc/sparc64/sys/Makefile.inc @@ -12,7 +12,7 @@ SRCS+= __sparc_sigtramp_setup.c \ CFLAGS+= -I${.CURDIR}/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 pipe.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 diff --git a/lib/libc/sparc64/sys/ptrace.S b/lib/libc/sparc64/sys/ptrace.S deleted file mode 100644 index eb415cd..0000000 --- a/lib/libc/sparc64/sys/ptrace.S +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Header: ptrace.s,v 1.2 91/12/20 01:59:00 leres Exp - * from: NetBSD: ptrace.S,v 1.4 2000/07/24 00:11:10 mycroft Exp - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93" -#if 0 - RCSID("$NetBSD: ptrace.S,v 1.4 2000/07/24 00:11:10 mycroft Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ -#include <machine/asm.h> -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -_SYSENTRY(ptrace) - save %sp, -CCFSZ, %sp - call CNAME(__error) - nop - stw %g0, [%o0] - restore - _SYSCALL(ptrace) - retl - nop -_SYSEND(ptrace) diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c index 9abf559..a2e39ed 100644 --- a/lib/libc/stdio/fgets.c +++ b/lib/libc/stdio/fgets.c @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93"; __FBSDID("$FreeBSD$"); #include "namespace.h" +#include <errno.h> #include <stdio.h> #include <string.h> #include "un-namespace.h" @@ -55,11 +56,16 @@ fgets(char * __restrict buf, int n, FILE * __restrict fp) char *s; unsigned char *p, *t; - if (n <= 0) /* sanity check */ - return (NULL); - FLOCKFILE(fp); ORIENT(fp, -1); + + if (n <= 0) { /* sanity check */ + fp->_flags |= __SERR; + errno = EINVAL; + FUNLOCKFILE(fp); + return (NULL); + } + s = buf; n--; /* leave space for NUL */ while (n != 0) { @@ -69,7 +75,7 @@ fgets(char * __restrict buf, int n, FILE * __restrict fp) if ((len = fp->_r) <= 0) { if (__srefill(fp)) { /* EOF/error: stop with partial or no line */ - if (s == buf) { + if (!__sfeof(fp) || s == buf) { FUNLOCKFILE(fp); return (NULL); } diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c index cf649fd..3074d44 100644 --- a/lib/libc/stdio/fgetwc.c +++ b/lib/libc/stdio/fgetwc.c @@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale) return (WEOF); do { nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); - if (nconv == (size_t)-1) - break; - else if (nconv == (size_t)-2) + if (nconv == (size_t)-1) { + fp->_flags |= __SERR; + return (WEOF); + } else if (nconv == (size_t)-2) continue; else if (nconv == 0) { fp->_p++; @@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale) return (wc); } } while (__srefill(fp) == 0); - fp->_flags |= __SERR; - errno = EILSEQ; + if (__sfeof(fp)) { + fp->_flags |= __SERR; + errno = EILSEQ; + } return (WEOF); } diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c index 34a80a0..037657c 100644 --- a/lib/libc/stdio/fgetwln.c +++ b/lib/libc/stdio/fgetwln.c @@ -47,11 +47,16 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) { wint_t wc; size_t len; + int savserr; + FIX_LOCALE(locale); FLOCKFILE(fp); ORIENT(fp, 1); + savserr = fp->_flags & __SERR; + fp->_flags &= ~__SERR; + len = 0; while ((wc = __fgetwc(fp, locale)) != WEOF) { #define GROW 512 @@ -64,7 +69,12 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) if (wc == L'\n') break; } - if (len == 0 || (wc == WEOF && !__sfeof(fp))) + /* fgetwc(3) may set both __SEOF and __SERR at once. */ + if (__sferror(fp)) + goto error; + + fp->_flags |= savserr; + if (len == 0) goto error; FUNLOCKFILE(fp); diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c index f7a63fe..8513a37 100644 --- a/lib/libc/stdio/fgetws.c +++ b/lib/libc/stdio/fgetws.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); wchar_t * fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale) { + int sret; wchar_t *wsp; size_t nconv; const char *src; @@ -56,23 +57,31 @@ fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale) ORIENT(fp, 1); if (n <= 0) { + fp->_flags |= __SERR; errno = EINVAL; goto error; } + wsp = ws; + if (n == 1) + goto ok; + if (fp->_r <= 0 && __srefill(fp)) - /* EOF */ + /* EOF or ferror */ goto error; - wsp = ws; + + sret = 0; do { src = fp->_p; nl = memchr(fp->_p, '\n', fp->_r); nconv = l->__mbsnrtowcs(wsp, &src, nl != NULL ? (nl - fp->_p + 1) : fp->_r, n - 1, &fp->_mbstate); - if (nconv == (size_t)-1) + if (nconv == (size_t)-1) { /* Conversion error */ + fp->_flags |= __SERR; goto error; + } if (src == NULL) { /* * We hit a null byte. Increment the character count, @@ -88,23 +97,30 @@ fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale) fp->_p = (unsigned char *)src; n -= nconv; wsp += nconv; - } while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 || - __srefill(fp) == 0)); - if (wsp == ws) - /* EOF */ + } while ((wsp == ws || wsp[-1] != L'\n') && n > 1 && (fp->_r > 0 || + (sret = __srefill(fp)) == 0)); + if (sret && !__sfeof(fp)) + /* ferror */ goto error; - if (!l->__mbsinit(&fp->_mbstate)) + if (!l->__mbsinit(&fp->_mbstate)) { /* Incomplete character */ + fp->_flags |= __SERR; + errno = EILSEQ; goto error; + } + if (wsp == ws) + /* EOF */ + goto error; +ok: *wsp = L'\0'; FUNLOCKFILE(fp); - return (ws); error: FUNLOCKFILE(fp); return (NULL); } + wchar_t * fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp) { diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 25bd4a3..0da0f82 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -59,6 +59,7 @@ INTERPOSED = \ poll \ ppoll \ pselect \ + ptrace \ read \ readv \ recvfrom \ diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 0e8c8bd..6dffefc 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd July 28, 2016 +.Dd August 28, 2016 .Dt PTRACE 2 .Os .Sh NAME @@ -104,7 +104,7 @@ Each traced process has a tracing event mask. An event in the traced process only reports a signal stop if the corresponding flag is set in the tracing event mask. The current set of tracing event flags include: -.Bl -tag -width ".Dv PTRACE_SYSCALL" +.Bl -tag -width "Dv PTRACE_SYSCALL" .It Dv PTRACE_EXEC Report a stop for a successful invocation of .Xr execve 2 . @@ -231,7 +231,7 @@ The .Fa request argument can be: -.Bl -tag -width 12n +.Bl -tag -width "Dv PT_GET_EVENT_MASK" .It Dv PT_TRACE_ME This request is the only one used by the traced process; it declares that the process expects to be traced by its parent. @@ -469,31 +469,31 @@ The fields in the .Vt "struct ptrace_lwpinfo" have the following meaning: .Bl -tag -width indent -compact -.It pl_lwpid +.It Va pl_lwpid LWP id of the thread -.It pl_event +.It Va pl_event Event that caused the stop. -Currently defined events are -.Bl -tag -width indent -compact -.It PL_EVENT_NONE +Currently defined events are: +.Bl -tag -width "Dv PL_EVENT_SIGNAL" -compact +.It Dv PL_EVENT_NONE No reason given -.It PL_EVENT_SIGNAL +.It Dv PL_EVENT_SIGNAL Thread stopped due to the pending signal .El -.It pl_flags +.It Va pl_flags Flags that specify additional details about observed stop. Currently defined flags are: .Bl -tag -width indent -compact -.It PL_FLAG_SCE +.It Dv PL_FLAG_SCE The thread stopped due to system call entry, right after the kernel is entered. The debugger may examine syscall arguments that are stored in memory and registers according to the ABI of the current process, and modify them, if needed. -.It PL_FLAG_SCX +.It Dv PL_FLAG_SCX The thread is stopped immediately before syscall is returning to the usermode. The debugger may examine system call return values in the ABI-defined registers and/or memory. -.It PL_FLAG_EXEC +.It Dv PL_FLAG_EXEC When .Dv PL_FLAG_SCX is set, this flag may be additionally specified to inform that the @@ -501,13 +501,13 @@ program being executed by debuggee process has been changed by successful execution of a system call from the .Fn execve 2 family. -.It PL_FLAG_SI +.It Dv PL_FLAG_SI Indicates that .Va pl_siginfo member of .Vt "struct ptrace_lwpinfo" contains valid information. -.It PL_FLAG_FORKED +.It Dv PL_FLAG_FORKED Indicates that the process is returning from a call to .Fn fork 2 that created a new child process. @@ -515,42 +515,42 @@ The process identifier of the new process is available in the .Va pl_child_pid member of .Vt "struct ptrace_lwpinfo" . -.It PL_FLAG_CHILD +.It Dv PL_FLAG_CHILD The flag is set for first event reported from a new child which is automatically attached when .Dv PTRACE_FORK is enabled. -.It PL_FLAG_BORN +.It Dv PL_FLAG_BORN This flag is set for the first event reported from a new LWP when .Dv PTRACE_LWP is enabled. It is reported along with .Dv PL_FLAG_SCX . -.It PL_FLAG_EXITED +.It Dv PL_FLAG_EXITED This flag is set for the last event reported by an exiting LWP when .Dv PTRACE_LWP is enabled. Note that this event is not reported when the last LWP in a process exits. The termination of the last thread is reported via a normal process exit event. -.It PL_FLAG_VFORKED +.It Dv PL_FLAG_VFORKED Indicates that the thread is returning from a call to .Xr vfork 2 that created a new child process. This flag is set in addition to .Dv PL_FLAG_FORKED . -.It PL_FLAG_VFORK_DONE +.It Dv PL_FLAG_VFORK_DONE Indicates that the thread has resumed after a child process created via .Xr vfork 2 has stopped sharing its address space with the traced process. .El -.It pl_sigmask +.It Va pl_sigmask The current signal mask of the LWP -.It pl_siglist +.It Va pl_siglist The current pending set of signals for the LWP. Note that signals that are delivered to the process would not appear on an LWP siglist until the thread is selected for delivery. -.It pl_siginfo +.It Va pl_siginfo The siginfo that accompanies the signal pending. Only valid for .Dv PL_EVENT_SIGNAL @@ -558,9 +558,9 @@ stop when .Dv PL_FLAG_SI is set in .Va pl_flags . -.It pl_tdname +.It Va pl_tdname The name of the thread. -.It pl_child_pid +.It Va pl_child_pid The process identifier of the new child process. Only valid for a .Dv PL_EVENT_SIGNAL @@ -568,7 +568,7 @@ stop when .Dv PL_FLAG_FORKED is set in .Va pl_flags . -.It pl_syscall_code +.It Va pl_syscall_code The ABI-specific identifier of the current system call. Note that for indirect system calls this field reports the indirected system call. @@ -578,7 +578,7 @@ or .Dv PL_FLAG_SCX is set in .Va pl_flags. -.It pl_syscall_narg +.It Va pl_syscall_narg The number of arguments passed to the current system call not counting the system call identifier. Note that for indirect system calls this field reports the arguments @@ -590,10 +590,10 @@ or is set in .Va pl_flags. .El -.It PT_GETNUMLWPS +.It Dv PT_GETNUMLWPS This request returns the number of kernel threads associated with the traced process. -.It PT_GETLWPLIST +.It Dv PT_GETLWPLIST This request can be used to get the current thread list. A pointer to an array of type .Vt lwpid_t @@ -604,15 +604,15 @@ with the array size specified by The return value from .Fn ptrace is the count of array entries filled in. -.It PT_SETSTEP +.It Dv PT_SETSTEP This request will turn on single stepping of the specified process. -.It PT_CLEARSTEP +.It Dv PT_CLEARSTEP This request will turn off single stepping of the specified process. -.It PT_SUSPEND +.It Dv PT_SUSPEND This request will suspend the specified thread. -.It PT_RESUME +.It Dv PT_RESUME This request will resume the specified thread. -.It PT_TO_SCE +.It Dv PT_TO_SCE This request will set the .Dv PTRACE_SCE event flag to trace all future system call entries and continue the process. @@ -622,7 +622,7 @@ and .Fa data arguments are used the same as for .Dv PT_CONTINUE. -.It PT_TO_SCX +.It Dv PT_TO_SCX This request will set the .Dv PTRACE_SCX event flag to trace all future system call exits and continue the process. @@ -632,7 +632,7 @@ and .Fa data arguments are used the same as for .Dv PT_CONTINUE. -.It PT_SYSCALL +.It Dv PT_SYSCALL This request will set the .Dv PTRACE_SYSCALL event flag to trace all future system call entries and exits and continue @@ -643,7 +643,7 @@ and .Fa data arguments are used the same as for .Dv PT_CONTINUE. -.It PT_FOLLOW_FORK +.It Dv PT_FOLLOW_FORK This request controls tracing for new child processes of a traced process. If .Fa data @@ -655,7 +655,7 @@ If is zero, .Dv PTRACE_FORK is cleared from the traced process's event tracing mask. -.It PT_LWP_EVENTS +.It Dv PT_LWP_EVENTS This request controls tracing of LWP creation and destruction. If .Fa data @@ -667,25 +667,25 @@ If is zero, .Dv PTRACE_LWP is cleared from the traced process's event tracing mask. -.It PT_GET_EVENT_MASK +.It Dv PT_GET_EVENT_MASK This request reads the traced process's event tracing mask into the integer pointed to by .Fa addr . The size of the integer must be passed in .Fa data . -.It PT_SET_EVENT_MASK +.It Dv PT_SET_EVENT_MASK This request sets the traced process's event tracing mask from the integer pointed to by .Fa addr . The size of the integer must be passed in .Fa data . -.It PT_VM_TIMESTAMP +.It Dv PT_VM_TIMESTAMP This request returns the generation number or timestamp of the memory map of the traced process as the return value from .Fn ptrace . This provides a low-cost way for the tracing process to determine if the VM map changed since the last time this request was made. -.It PT_VM_ENTRY +.It Dv PT_VM_ENTRY This request is used to iterate over the entries of the VM map of the traced process. The @@ -906,7 +906,13 @@ to return \-1 as a non-error value; to disambiguate, .Va errno -can be set to 0 before the call and checked afterwards. +is set to 0 in the libc wrapper for the +.Fn ptrace +system call and +.Fn ptrace +callers can reliably check +.Va errno +for non-zero value afterwards. .Sh ERRORS The .Fn ptrace diff --git a/lib/libc/sys/ptrace.c b/lib/libc/sys/ptrace.c new file mode 100644 index 0000000..2bb615f --- /dev/null +++ b/lib/libc/sys/ptrace.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/ptrace.h> +#include <errno.h> +#include "libc_private.h" + +__weak_reference(_ptrace, ptrace); + +int +_ptrace(int request, pid_t pid, caddr_t addr, int data) +{ + + errno = 0; + return (__sys_ptrace(request, pid, addr, data)); +} diff --git a/lib/libc/tests/resolv/resolv_test.c b/lib/libc/tests/resolv/resolv_test.c index 74e89b1..1da42e3 100644 --- a/lib/libc/tests/resolv/resolv_test.c +++ b/lib/libc/tests/resolv/resolv_test.c @@ -291,7 +291,7 @@ do { \ ATF_TC(getaddrinfo_test); ATF_TC_HEAD(getaddrinfo_test, tc) { - atf_tc_set_md_var(tc, "timeout", "450"); + atf_tc_set_md_var(tc, "timeout", "1200"); } ATF_TC_BODY(getaddrinfo_test, tc) { @@ -301,7 +301,7 @@ ATF_TC_BODY(getaddrinfo_test, tc) ATF_TC(gethostby_test); ATF_TC_HEAD(gethostby_test, tc) { - atf_tc_set_md_var(tc, "timeout", "450"); + atf_tc_set_md_var(tc, "timeout", "1200"); } ATF_TC_BODY(gethostby_test, tc) { @@ -312,7 +312,7 @@ ATF_TC_BODY(gethostby_test, tc) ATF_TC(getipnodeby_test); ATF_TC_HEAD(getipnodeby_test, tc) { - atf_tc_set_md_var(tc, "timeout", "450"); + atf_tc_set_md_var(tc, "timeout", "1200"); } ATF_TC_BODY(getipnodeby_test, tc) { |