Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src Pull up following revision(s) (requested by kamil in tick...



details:   https://anonhg.NetBSD.org/src/rev/509fdf5322e0
branches:  netbsd-8
changeset: 434706:509fdf5322e0
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Mar 06 09:52:09 2018 +0000

description:
Pull up following revision(s) (requested by kamil in ticket #602):
        doc/CHANGES{,.prev}: revision 1.138
        sys/sys/ptrace.h: revision 1.63
        lib/libc/sys/ptrace.2: revision 1.68
        sys/kern/sys_ptrace_common.c: revision 1.35 (via patch)
        tests/lib/libc/sys/t_ptrace_wait.c: revision 1.23

Remove PT_GET_SIGMASK / PT_SET_SIGMASK

These operations cloned Linux's specific PTRACE_GETSIGMASK /
PTRACE_SETSIGMASK.

This feature was useful in applications like rr/criu/reptyr-like, where
the ptrace(2) interface is abused for the purpose of constructing an
arbitrary
process. It's not reliable and not portable. For the NetBSD case it will =
be
better to invent something dedicated for serializing and deserializing a
process with threads.

Noted on tech-toolchain@ and blog entry
"LLDB restoration and return to ptrace(2)"
https://blog.netbsd.org/tnf/entry/lldb_restoration_and_return_to

diffstat:

 doc/CHANGES                        |    4 +-
 lib/libc/sys/ptrace.2              |   27 +-
 sys/kern/sys_ptrace_common.c       |   38 +--
 sys/sys/ptrace.h                   |   14 +-
 tests/lib/libc/sys/t_ptrace_wait.c |  500 +------------------------------------
 5 files changed, 13 insertions(+), 570 deletions(-)

diffs (truncated from 695 to 300 lines):

diff -r bf52c847ece6 -r 509fdf5322e0 doc/CHANGES
--- a/doc/CHANGES       Tue Mar 06 09:27:27 2018 +0000
+++ b/doc/CHANGES       Tue Mar 06 09:52:09 2018 +0000
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2286.2.2 $>
+# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2286.2.3 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -355,6 +355,8 @@
        amd64: Use fine-grained permissions for architecture-specific memory
                areas (W^X). [maxv 20160725]
        sdtemp(4): Add support for Atmel AT30TS00, AT30TSE004, Giantec
+       kernel: SMBFS uses low-overhead NT Directory Change Notify SMB to watch
+               for vnode kqueue(2) events on directories [jdolecek 20030407]
                GT30TS00, GT34TS02, Microchip MCP9804, MCP98244, IDT
                TS3000GB[02], TS3001GB2, TSE200[24]GB2 and On Semiconductor
                CAT34TS04. [msaitoh 20160726]
diff -r bf52c847ece6 -r 509fdf5322e0 lib/libc/sys/ptrace.2
--- a/lib/libc/sys/ptrace.2     Tue Mar 06 09:27:27 2018 +0000
+++ b/lib/libc/sys/ptrace.2     Tue Mar 06 09:52:09 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ptrace.2,v 1.67 2017/06/03 19:41:14 abhinav Exp $
+.\"    $NetBSD: ptrace.2,v 1.67.2.1 2018/03/06 09:52:09 martin Exp $
 .\"
 .\" This file is in the public domain.
 .Dd April 7, 2017
@@ -561,31 +561,6 @@
 .Fa data
 argument should be set to
 .Li sizeof(struct ptrace_siginfo) .
-.It Dv PT_SET_SIGMASK
-This request loads the traced process' signal mask from
-.Dq Li "sigset_t"
-(defined in
-.In sys/sigtypes.h )
-pointed to by
-.Fa addr .
-The
-.Fa data
-argument contains the LWP ID of the thread whose registers are to
-be written.
-If zero is supplied, the first thread of the process is written.
-.It Dv PT_GET_SIGMASK
-This request is the converse of
-.Dv PT_SET_SIGMASK ;
-it reads the traced process' signal mask into
-.Dq Li "sigset_t"
-(defined in
-.In sys/sigtypes.h )
-pointed to by
-.Fa addr .
-The
-.Fa data
-argument contains the LWP ID of the thread whose mask is to be read.
-If zero is supplied, the first thread of the process is read.
 .It Dv PT_RESUME
 Allow execution of a specified thread,
 change its state from suspended to continued.
diff -r bf52c847ece6 -r 509fdf5322e0 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Tue Mar 06 09:27:27 2018 +0000
+++ b/sys/kern/sys_ptrace_common.c      Tue Mar 06 09:52:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.22 2017/05/03 15:53:31 kamil Exp $     */
+/*     $NetBSD: sys_ptrace_common.c,v 1.22.2.1 2018/03/06 09:52:09 martin Exp $        */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22 2017/05/03 15:53:31 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.1 2018/03/06 09:52:09 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -213,8 +213,6 @@
        case PT_GET_PROCESS_STATE:
        case PT_SET_SIGINFO:
        case PT_GET_SIGINFO:
-       case PT_SET_SIGMASK:
-       case PT_GET_SIGMASK:
 #ifdef __HAVE_PTRACE_MACHDEP
        PTRACE_MACHDEP_REQUEST_CASES
 #endif
@@ -408,8 +406,6 @@
        case  PT_IO:
        case  PT_SET_SIGINFO:
        case  PT_GET_SIGINFO:
-       case  PT_SET_SIGMASK:
-       case  PT_GET_SIGMASK:
 #ifdef PT_GETREGS
        case  PT_GETREGS:
 #endif
@@ -1120,36 +1116,6 @@
 
                break;
 
-       case  PT_SET_SIGMASK:
-               write = 1;
-
-       case  PT_GET_SIGMASK:
-               /* write = 0 done above. */
-
-               tmp = data;
-               if (tmp != 0 && t->p_nlwps > 1) {
-                       lwp_delref(lt);
-                       mutex_enter(t->p_lock);
-                       lt = lwp_find(t, tmp);
-                       if (lt == NULL) {
-                               mutex_exit(t->p_lock);
-                               error = ESRCH;
-                               break;
-                       }
-                       lwp_addref(lt);
-                       mutex_exit(t->p_lock);
-               }
-
-               if (lt->l_flag & LW_SYSTEM)
-                       error = EINVAL;
-               else if (write == 1) {
-                       error = copyin(addr, &lt->l_sigmask, sizeof(sigset_t));
-                       sigminusset(&sigcantmask, &lt->l_sigmask);
-               } else
-                       error = copyout(&lt->l_sigmask, addr, sizeof(sigset_t));
-                       
-               break;
-
        case  PT_RESUME:
                write = 1;
 
diff -r bf52c847ece6 -r 509fdf5322e0 sys/sys/ptrace.h
--- a/sys/sys/ptrace.h  Tue Mar 06 09:27:27 2018 +0000
+++ b/sys/sys/ptrace.h  Tue Mar 06 09:52:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptrace.h,v 1.60 2017/03/24 17:40:44 christos Exp $     */
+/*     $NetBSD: ptrace.h,v 1.60.6.1 2018/03/06 09:52:09 martin Exp $   */
 
 /*-
  * Copyright (c) 1984, 1993
@@ -55,10 +55,8 @@
 #define        PT_GET_PROCESS_STATE    18      /* get process state, defined below */
 #define        PT_SET_SIGINFO          19      /* set signal state, defined below */
 #define        PT_GET_SIGINFO          20      /* get signal state, defined below */
-#define        PT_SET_SIGMASK          21      /* set signal mask */
-#define        PT_GET_SIGMASK          22      /* get signal mask */
-#define        PT_RESUME               23      /* allow execution of the LWP */
-#define        PT_SUSPEND              24      /* prevent execution of the LWP */
+#define        PT_RESUME               21      /* allow execution of the LWP */
+#define        PT_SUSPEND              22      /* prevent execution of the LWP */
 
 #define        PT_FIRSTMACH            32      /* for machine-specific requests */
 #include <machine/ptrace.h>            /* machine-specific requests, if any */
@@ -85,10 +83,8 @@
 /* 18 */    "PT_GET_PROCESS_STATE", \
 /* 19 */    "PT_SET_SIGINFO", \
 /* 20 */    "PT_GET_SIGINFO", \
-/* 21 */    "PT_GET_SIGMASK", \
-/* 22 */    "PT_GET_SIGMASK", \
-/* 23 */    "PT_RESUME", \
-/* 24 */    "PT_SUSPEND",
+/* 21 */    "PT_RESUME", \
+/* 22 */    "PT_SUSPEND",
 
 /* PT_{G,S}EVENT_MASK */
 typedef struct ptrace_event {
diff -r bf52c847ece6 -r 509fdf5322e0 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Tue Mar 06 09:27:27 2018 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Tue Mar 06 09:52:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.9.2.1 2018/02/25 20:59:46 snj Exp $        */
+/*     $NetBSD: t_ptrace_wait.c,v 1.9.2.2 2018/03/06 09:52:09 martin Exp $     */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.9.2.1 2018/02/25 20:59:46 snj Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.9.2.2 2018/03/06 09:52:09 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -6555,492 +6555,6 @@
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 
-ATF_TC(getsigmask1);
-ATF_TC_HEAD(getsigmask1, tc)
-{
-       atf_tc_set_md_var(tc, "descr",
-           "Verify that plain PT_SET_SIGMASK can be called");
-}
-
-ATF_TC_BODY(getsigmask1, tc)
-{
-       const int exitval = 5;
-       const int sigval = SIGSTOP;
-       pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-       int status;
-#endif
-       sigset_t mask;
-
-       DPRINTF("Before forking process PID=%d\n", getpid());
-       SYSCALL_REQUIRE((child = fork()) != -1);
-       if (child == 0) {
-               DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-               FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-               DPRINTF("Before raising %s from child\n", strsignal(sigval));
-               FORKEE_ASSERT(raise(sigval) == 0);
-
-               DPRINTF("Before exiting of the child process\n");
-               _exit(exitval);
-       }
-       DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-       TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
-       validate_status_stopped(status, sigval);
-
-       DPRINTF("Before calling PT_GET_SIGMASK\n");
-       SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &mask, 0) != -1);
-
-       DPRINTF("Before resuming the child process where it left off and "
-           "without signal to be sent\n");
-       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-       TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
-       validate_status_exited(status, exitval);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-       TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
-ATF_TC(getsigmask2);
-ATF_TC_HEAD(getsigmask2, tc)
-{
-       atf_tc_set_md_var(tc, "descr",
-           "Verify that PT_SET_SIGMASK reports correct mask from tracee");
-}
-
-ATF_TC_BODY(getsigmask2, tc)
-{
-       const int exitval = 5;
-       const int sigval = SIGSTOP;
-       const int sigmasked = SIGTRAP;
-       pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-       int status;
-#endif
-       sigset_t mask;
-       sigset_t expected_mask;
-       ATF_REQUIRE(sigemptyset(&mask) == 0);
-       ATF_REQUIRE(sigemptyset(&expected_mask) == 0);
-       ATF_REQUIRE(sigaddset(&expected_mask, sigmasked) == 0);
-
-       DPRINTF("Before forking process PID=%d\n", getpid());
-       SYSCALL_REQUIRE((child = fork()) != -1);
-       if (child == 0) {
-               DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-               FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-               sigaddset(&mask, sigmasked);
-               sigprocmask(SIG_BLOCK, &mask, NULL);
-
-               DPRINTF("Before raising %s from child\n", strsignal(sigval));
-               FORKEE_ASSERT(raise(sigval) == 0);
-
-               DPRINTF("Before exiting of the child process\n");
-               _exit(exitval);
-       }
-       DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-       TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
-       validate_status_stopped(status, sigval);
-
-       DPRINTF("Before calling PT_GET_SIGMASK\n");
-       SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &mask, 0) != -1);
-
-       ATF_REQUIRE(memcmp(&mask, &expected_mask, sizeof(sigset_t)) == 0);
-
-       DPRINTF("Before resuming the child process where it left off and "
-           "without signal to be sent\n");
-       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-       TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
-       validate_status_exited(status, exitval);
-
-       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);



Home | Main Index | Thread Index | Old Index