From a3f025ebbf077214bc37d6a184ba63670ec978da Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Mon, 5 Mar 2018 11:55:48 +0100 Subject: [PATCH] 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 --- doc/CHANGES | 2 - lib/libc/sys/ptrace.2 | 25 -- sys/kern/sys_ptrace_common.c | 34 --- sys/sys/ptrace.h | 12 +- tests/lib/libc/sys/t_ptrace_wait.c | 496 ------------------------------------- 5 files changed, 4 insertions(+), 565 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index 952f2343b728..6845831cbdd7 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -468,8 +468,6 @@ Changes from NetBSD 7.0 to NetBSD 8.0: libc: Add accept4 function for compatibility [maya 20170208] 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] diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 1549c0f9dd9c..3cfa3f4ab50b 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -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. diff --git a/sys/kern/sys_ptrace_common.c b/sys/kern/sys_ptrace_common.c index ae8ec4b05ae3..8357a297533f 100644 --- a/sys/kern/sys_ptrace_common.c +++ b/sys/kern/sys_ptrace_common.c @@ -213,8 +213,6 @@ ptrace_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie, 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 @@ do_ptrace(struct ptrace_methods *ptm, struct lwp *l, int req, pid_t pid, 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 @@ do_ptrace(struct ptrace_methods *ptm, struct lwp *l, int req, pid_t pid, 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, <->l_sigmask, sizeof(sigset_t)); - sigminusset(&sigcantmask, <->l_sigmask); - } else - error = copyout(<->l_sigmask, addr, sizeof(sigset_t)); - - break; - case PT_RESUME: write = 1; diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 775bf5345c04..7a1cb2580d0b 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -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-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 --git a/tests/lib/libc/sys/t_ptrace_wait.c b/tests/lib/libc/sys/t_ptrace_wait.c index 0a625793a0c8..e6808ec96e25 100644 --- a/tests/lib/libc/sys/t_ptrace_wait.c +++ b/tests/lib/libc/sys/t_ptrace_wait.c @@ -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); -- 2.16.2