Source-Changes-HG archive

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

[src/netbsd-9]: src/tests/lib/libc/sys Apply patch, requested by kamil in tic...



details:   https://anonhg.NetBSD.org/src/rev/aba9aa5ab79a
branches:  netbsd-9
changeset: 1001779:aba9aa5ab79a
user:      martin <martin%NetBSD.org@localhost>
date:      Mon May 25 17:00:20 2020 +0000

description:
Apply patch, requested by kamil in ticket #925:

Cherry-pick from:

        tests/lib/libc/sys/t_ptrace_fork_wait.h 1.2

Fix race in fork_singalmasked

ELF RTLD after rtld.c r. 1.204 introduced locking that wraps the fork
syscall. This locking changes signal mask of the calling process during
the forking process.

Instead of comparing old and new signal mask, just after the forking
operation, check whether the expected signal is still masked and in
another test whether it is still ignored.

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.c |  35 ++++++++++++++++-------------------
 1 files changed, 16 insertions(+), 19 deletions(-)

diffs (98 lines):

diff -r 1af14d326449 -r aba9aa5ab79a tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Mon May 25 15:54:15 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Mon May 25 17:00:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.131.2.6 2019/10/23 19:25:39 martin Exp $   */
+/*     $NetBSD: t_ptrace_wait.c,v 1.131.2.7 2020/05/25 17:00:20 martin Exp $   */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.6 2019/10/23 19:25:39 martin Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.7 2020/05/25 17:00:20 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -5824,11 +5824,8 @@
 
        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 0%s%s%s%s in EVENT_MASK for the child %d\n",
            strcmp(fn, "spawn") == 0 ? "|PTRACE_POSIX_SPAWN" : "",
@@ -5874,8 +5871,8 @@
                            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) {
@@ -5891,8 +5888,8 @@
                            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(
@@ -5937,8 +5934,8 @@
                            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) {
@@ -5954,8 +5951,8 @@
                            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(
@@ -6016,8 +6013,8 @@
                            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) {
@@ -6033,8 +6030,8 @@
                            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(



Home | Main Index | Thread Index | Old Index