Module Name: src Committed By: kamil Date: Mon May 11 21:18:11 UTC 2020
Modified Files: src/tests/lib/libc/sys: t_ptrace_clone_wait.h Log Message: Fix potential race in ptrace(2) clone(2) tests Instead of comparing old and new signal mask, just after the cloning operation, check whether the expected signal is still masked and in another test whether it is still ignored. Catch up after t_ptrace_fork_wait.h r. 1.2. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_clone_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libc/sys/t_ptrace_clone_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.3 --- src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2 Mon May 4 22:24:31 2020 +++ src/tests/lib/libc/sys/t_ptrace_clone_wait.h Mon May 11 21:18:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_clone_wait.h,v 1.2 2020/05/04 22:24:31 kamil Exp $ */ +/* $NetBSD: t_ptrace_clone_wait.h,v 1.3 2020/05/11 21:18:11 kamil Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -414,11 +414,8 @@ clone_body2(int flags, bool masked, bool FORKEE_ASSERT_EQ(sysctl(name, namelen, &kp, &len, NULL, 0), 0); - if (masked) - kp_sigmask = kp.p_sigmask; - - if (ignored) - kp_sigignore = kp.p_sigignore; + kp_sigmask = kp.p_sigmask; + kp_sigignore = kp.p_sigignore; DPRINTF("Set PTRACE_FORK | PTRACE_VFORK | PTRACE_VFORK_DONE in " "EVENT_MASK for the child %d\n", child); @@ -451,8 +448,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -468,8 +465,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE( @@ -510,8 +507,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -527,8 +524,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE(