summaryrefslogtreecommitdiff
path: root/tests/lib/libc
diff options
context:
space:
mode:
authorkamil <kamil@NetBSD.org>2020-05-11 21:18:11 +0000
committerkamil <kamil@NetBSD.org>2020-05-11 21:18:11 +0000
commitc0b6083ca5bf4eabc3d46b8c42fa95d13e031da0 (patch)
treecef6ec39f63db56172497454923321e1b5b7b118 /tests/lib/libc
parent7446cb625e6c290fc287c2bcf7ade6df0957742e (diff)
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.
Diffstat (limited to 'tests/lib/libc')
-rw-r--r--tests/lib/libc/sys/t_ptrace_clone_wait.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/tests/lib/libc/sys/t_ptrace_clone_wait.h b/tests/lib/libc/sys/t_ptrace_clone_wait.h
index 83dfd1f2a82..47abcd8da05 100644
--- a/tests/lib/libc/sys/t_ptrace_clone_wait.h
+++ b/tests/lib/libc/sys/t_ptrace_clone_wait.h
@@ -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 ignored)
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 ignored)
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 ignored)
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 ignored)
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 ignored)
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(