svn commit: r305341 - in stable/10/lib/libc: amd64/sys arm/sys i386/sys ia64/sys include mips/sys powerpc/sys powerpc64/sys sparc64/sys sys
Konstantin Belousov
kib at FreeBSD.org
Sat Sep 3 11:09:49 UTC 2016
Author: kib
Date: Sat Sep 3 11:09:47 2016
New Revision: 305341
URL: https://svnweb.freebsd.org/changeset/base/305341
Log:
MFC r304928:
Do not obliterate errno value in the main thread during ptrace(2) call on x86.
MFC r304931:
Follow ABI when calling __error from the ptrace(2) wrapper.
MFC r305012:
Rewrite ptrace(2) wrappers in C.
MFC r305022:
Restore the requirement of setting errno to zero before calling ptrace(2).
Added:
stable/10/lib/libc/sys/ptrace.c
- copied unchanged from r305012, head/lib/libc/sys/ptrace.c
Deleted:
stable/10/lib/libc/amd64/sys/ptrace.S
stable/10/lib/libc/arm/sys/ptrace.S
stable/10/lib/libc/i386/sys/ptrace.S
stable/10/lib/libc/ia64/sys/ptrace.S
stable/10/lib/libc/mips/sys/ptrace.S
stable/10/lib/libc/powerpc/sys/ptrace.S
stable/10/lib/libc/powerpc64/sys/ptrace.S
stable/10/lib/libc/sparc64/sys/ptrace.S
Modified:
stable/10/lib/libc/amd64/sys/Makefile.inc
stable/10/lib/libc/arm/sys/Makefile.inc
stable/10/lib/libc/i386/sys/Makefile.inc
stable/10/lib/libc/ia64/sys/Makefile.inc
stable/10/lib/libc/include/libc_private.h
stable/10/lib/libc/mips/sys/Makefile.inc
stable/10/lib/libc/powerpc/sys/Makefile.inc
stable/10/lib/libc/powerpc64/sys/Makefile.inc
stable/10/lib/libc/sparc64/sys/Makefile.inc
stable/10/lib/libc/sys/Makefile.inc
stable/10/lib/libc/sys/ptrace.2
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/lib/libc/amd64/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/amd64/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/amd64/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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:
Modified: stable/10/lib/libc/arm/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/arm/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/arm/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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
Modified: stable/10/lib/libc/i386/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/i386/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/i386/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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 pipe.S \
sbrk.S setlogin.S sigreturn.S syscall.S
# Don't generate default code for these syscalls:
Modified: stable/10/lib/libc/ia64/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/ia64/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/ia64/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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:
Modified: stable/10/lib/libc/include/libc_private.h
==============================================================================
--- stable/10/lib/libc/include/libc_private.h Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/include/libc_private.h Sat Sep 3 11:09:47 2016 (r305341)
@@ -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 *);
Modified: stable/10/lib/libc/mips/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/mips/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/mips/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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 \
Modified: stable/10/lib/libc/powerpc/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/powerpc/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/powerpc/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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
Modified: stable/10/lib/libc/powerpc64/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/powerpc64/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/powerpc64/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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
Modified: stable/10/lib/libc/sparc64/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/sparc64/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/sparc64/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -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
Modified: stable/10/lib/libc/sys/Makefile.inc
==============================================================================
--- stable/10/lib/libc/sys/Makefile.inc Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/sys/Makefile.inc Sat Sep 3 11:09:47 2016 (r305341)
@@ -59,6 +59,7 @@ INTERPOSED = \
poll \
ppoll \
pselect \
+ ptrace \
read \
readv \
recvfrom \
Modified: stable/10/lib/libc/sys/ptrace.2
==============================================================================
--- stable/10/lib/libc/sys/ptrace.2 Sat Sep 3 11:00:29 2016 (r305340)
+++ stable/10/lib/libc/sys/ptrace.2 Sat Sep 3 11:09:47 2016 (r305341)
@@ -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
@@ -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
Copied: stable/10/lib/libc/sys/ptrace.c (from r305012, head/lib/libc/sys/ptrace.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/10/lib/libc/sys/ptrace.c Sat Sep 3 11:09:47 2016 (r305341, copy of r305012, head/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));
+}
More information about the svn-src-all
mailing list