Module Name:    src
Committed By:   kamil
Date:           Mon Mar  5 11:24:35 UTC 2018

Modified Files:
        src/doc: CHANGES.prev
        src/lib/libc/sys: ptrace.2
        src/sys/kern: sys_ptrace_common.c
        src/sys/sys: ptrace.h
        src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/doc/CHANGES.prev
cvs rdiff -u -r1.67 -r1.68 src/lib/libc/sys/ptrace.2
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/sys_ptrace_common.c
cvs rdiff -u -r1.62 -r1.63 src/sys/sys/ptrace.h
cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libc/sys/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES.prev
diff -u src/doc/CHANGES.prev:1.137 src/doc/CHANGES.prev:1.138
--- src/doc/CHANGES.prev:1.137	Thu Feb  8 08:32:30 2018
+++ src/doc/CHANGES.prev	Mon Mar  5 11:24:35 2018
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.137 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.138 $>
 
 
 Changes from 386bsd 0.1 + patchkit 0.2.2 to NetBSD 0.8:
@@ -12169,8 +12169,6 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	bpf(4): Make it MP-safe [ozaki-r 20170209]
 	file(1): Upgraded to 5.30. [christos 20170210]
 	byacc: update to 20170201 [christos 20170211]
-	ptrace(2): Add signal mask information accessors API:
-		PT_GET_SIGMASK and PT_SET_SIGMASK [kamil 20170212]
 	postfix(1): Import version 3.1.4. [christos 20170213]
 	l2tp(4): Add L2TPv3 interface. [knakahara 20170216]
 	siginfo(2): Add new si_code for SIGTRAP: TRAP_DBREG [kamil 20170217]
@@ -12228,4 +12226,3 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	opencrypto(9): Complete MP-ification [knakahara 20170731]
 	ipsec(4): Make it MP-safe [ozaki-r 20170809]
 	evbmips: Merge sbmips port into evbmips. [mrg 20170815]
-

Index: src/lib/libc/sys/ptrace.2
diff -u src/lib/libc/sys/ptrace.2:1.67 src/lib/libc/sys/ptrace.2:1.68
--- src/lib/libc/sys/ptrace.2:1.67	Sat Jun  3 19:41:14 2017
+++ src/lib/libc/sys/ptrace.2	Mon Mar  5 11:24:35 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ptrace.2,v 1.67 2017/06/03 19:41:14 abhinav Exp $
+.\"	$NetBSD: ptrace.2,v 1.68 2018/03/05 11:24:35 kamil Exp $
 .\"
 .\" This file is in the public domain.
 .Dd April 7, 2017
@@ -561,31 +561,6 @@ The
 .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.

Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.34 src/sys/kern/sys_ptrace_common.c:1.35
--- src/sys/kern/sys_ptrace_common.c:1.34	Mon Jan  8 06:10:30 2018
+++ src/sys/kern/sys_ptrace_common.c	Mon Mar  5 11:24:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.34 2018/01/08 06:10:30 christos Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.35 2018/03/05 11:24:34 kamil 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.34 2018/01/08 06:10:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.35 2018/03/05 11:24:34 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -249,8 +249,6 @@ ptrace_listener_cb(kauth_cred_t cred, ka
 	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
@@ -411,8 +409,6 @@ ptrace_allowed(struct lwp *l, int req, s
 	case PT_IO:
 	case PT_SET_SIGINFO:
 	case PT_GET_SIGINFO:
-	case PT_SET_SIGMASK:
-	case PT_GET_SIGMASK:
 	case_PT_GETREGS
 	case_PT_SETREGS
 	case_PT_GETFPREGS
@@ -714,24 +710,6 @@ ptrace_lwpinfo(struct proc *t, struct lw
 }
 
 static int
-ptrace_sigmask(struct proc *t, struct lwp **lt, int rq, void *addr, size_t data)
-{
-	int error;
-
-	if ((error = ptrace_update_lwp(t, lt, data)) != 0)
-		return error;
-
-	if (rq == PT_GET_SIGMASK)
-		return copyout(&(*lt)->l_sigmask, addr, sizeof(sigset_t));
-
-	error = copyin(addr, &(*lt)->l_sigmask, sizeof(sigset_t));
-	if (error)
-		return error;
-	sigminusset(&sigcantmask, &(*lt)->l_sigmask);
-	return 0;
-}
-
-static int
 ptrace_startstop(struct proc *t, struct lwp **lt, int rq, void *addr,
     size_t data)
 {
@@ -1290,11 +1268,6 @@ do_ptrace(struct ptrace_methods *ptm, st
 		error = ptrace_get_siginfo(t, ptm, addr, data);
 		break;
 
-	case PT_SET_SIGMASK:
-	case PT_GET_SIGMASK:
-		error = ptrace_sigmask(t, &lt, req, addr, data);
-		break;
-
 	case PT_RESUME:
 	case PT_SUSPEND:
 		error = ptrace_startstop(t, &lt, req, addr, data);

Index: src/sys/sys/ptrace.h
diff -u src/sys/sys/ptrace.h:1.62 src/sys/sys/ptrace.h:1.63
--- src/sys/sys/ptrace.h:1.62	Sun Dec 17 20:59:28 2017
+++ src/sys/sys/ptrace.h	Mon Mar  5 11:24:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.62 2017/12/17 20:59:28 christos Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.63 2018/03/05 11:24:34 kamil 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 {

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.22 src/tests/lib/libc/sys/t_ptrace_wait.c:1.23
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.22	Thu Dec 28 18:41:33 2017
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon Mar  5 11:24:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.22 2017/12/28 18:41:33 christos Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.23 2018/03/05 11:24:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.22 2017/12/28 18:41:33 christos Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.23 2018/03/05 11:24:34 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -6555,492 +6555,6 @@ ATF_TC_BODY(signal10, tc)
 	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);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
-ATF_TC(setsigmask1);
-ATF_TC_HEAD(setsigmask1, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that plain PT_SET_SIGMASK can be called with empty mask");
-}
-
-ATF_TC_BODY(setsigmask1, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t mask;
-	ATF_REQUIRE(sigemptyset(&mask) == 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);
-
-		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_SET_SIGMASK for empty mask\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_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(setsigmask2);
-ATF_TC_HEAD(setsigmask2, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that sigmask is preserved between PT_GET_SIGMASK and "
-	    "PT_SET_SIGMASK");
-}
-
-ATF_TC_BODY(setsigmask2, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t new_mask;
-	sigset_t mask;
-	ATF_REQUIRE(sigemptyset(&new_mask) == 0);
-	ATF_REQUIRE(sigemptyset(&mask) == 0);
-	ATF_REQUIRE(sigaddset(&mask, SIGINT) == 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);
-
-		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_SET_SIGMASK for new mask with SIGINT\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_SIGMASK, child, &mask, 0) != -1);
-
-	DPRINTF("Before calling PT_GET_SIGMASK to store it in new_mask\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &new_mask, 0) != -1);
-
-	ATF_REQUIRE(memcmp(&mask, &new_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);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
-ATF_TC(setsigmask3);
-ATF_TC_HEAD(setsigmask3, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that sigmask is preserved between PT_GET_SIGMASK, process "
-	    "resumed and PT_SET_SIGMASK");
-}
-
-ATF_TC_BODY(setsigmask3, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t new_mask;
-	sigset_t mask;
-	ATF_REQUIRE(sigemptyset(&new_mask) == 0);
-	ATF_REQUIRE(sigemptyset(&mask) == 0);
-	ATF_REQUIRE(sigaddset(&mask, SIGINT) == 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);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		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_SET_SIGMASK for new mask with SIGINT\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_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_stopped(status, sigval);
-
-	DPRINTF("Before calling PT_GET_SIGMASK to store it in new_mask\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &new_mask, 0) != -1);
-
-	ATF_REQUIRE(memcmp(&mask, &new_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);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
-ATF_TC(setsigmask4);
-ATF_TC_HEAD(setsigmask4, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that new sigmask is visible in tracee");
-}
-
-ATF_TC_BODY(setsigmask4, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	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, SIGINT) == 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);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		sigprocmask(0, NULL, &mask);
-
-		FORKEE_ASSERT
-		    (memcmp(&mask, &expected_mask, sizeof(sigset_t)) == 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_SET_SIGMASK for new mask with SIGINT\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_SIGMASK, child, &expected_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(setsigmask5);
-ATF_TC_HEAD(setsigmask5, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that sigmask cannot be set to SIGKILL");
-}
-
-ATF_TC_BODY(setsigmask5, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t new_mask;
-	sigset_t mask;
-	ATF_REQUIRE(sigemptyset(&new_mask) == 0);
-	ATF_REQUIRE(sigemptyset(&mask) == 0);
-	ATF_REQUIRE(sigaddset(&mask, SIGKILL) == 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);
-
-		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_SET_SIGMASK for new mask with SIGINT\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_SIGMASK, child, &mask, 0) != -1);
-
-	DPRINTF("Before calling PT_GET_SIGMASK to store it in new_mask\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &new_mask, 0) != -1);
-
-	ATF_REQUIRE(memcmp(&mask, &new_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);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
-ATF_TC(setsigmask6);
-ATF_TC_HEAD(setsigmask6, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	    "Verify that sigmask cannot be set to SIGSTOP");
-}
-
-ATF_TC_BODY(setsigmask6, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t new_mask;
-	sigset_t mask;
-	ATF_REQUIRE(sigemptyset(&new_mask) == 0);
-	ATF_REQUIRE(sigemptyset(&mask) == 0);
-	ATF_REQUIRE(sigaddset(&mask, SIGSTOP) == 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);
-
-		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_SET_SIGMASK for new mask with SIGINT\n");
-	SYSCALL_REQUIRE(ptrace(PT_SET_SIGMASK, child, &mask, 0) != -1);
-
-	DPRINTF("Before calling PT_GET_SIGMASK to store it in new_mask\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGMASK, child, &new_mask, 0) != -1);
-
-	ATF_REQUIRE(memcmp(&mask, &new_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);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-
 static void
 lwp_main_stop(void *arg)
 {
@@ -7681,16 +7195,6 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, resume1);
 
-	ATF_TP_ADD_TC(tp, getsigmask1);
-	ATF_TP_ADD_TC(tp, getsigmask2);
-
-	ATF_TP_ADD_TC(tp, setsigmask1);
-	ATF_TP_ADD_TC(tp, setsigmask2);
-	ATF_TP_ADD_TC(tp, setsigmask3);
-	ATF_TP_ADD_TC(tp, setsigmask4);
-	ATF_TP_ADD_TC(tp, setsigmask5);
-	ATF_TP_ADD_TC(tp, setsigmask6);
-
 	ATF_TP_ADD_TC(tp, syscall1);
 
 	ATF_TP_ADD_TC(tp, syscallemu1);

Reply via email to