]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: PR_DEATHSIG is reset after changing id/gid 38875/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 11 Sep 2025 12:16:26 +0000 (13:16 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 11 Sep 2025 12:37:34 +0000 (13:37 +0100)
Child processes are left hanging on abort() as these child procs
freeze(), so test suites hang as well when test-namespace fails,
and processes are leaked.

From the docs:

The parent-death signal setting is also cleared upon changes to any of
the following thread credentials: effective user ID, effective group ID,
filesystem user ID, or filesystem group ID.

Set the deathsig again after changing id.

Follow-up for 2ade8218598afba0802b1007535b5c8deaeceb58

src/test/test-namespace.c

index 79c9431088981c62ace46417ab71e00f258188cd..83d47d62b0c476cd9d2825892ff79933871d6f72 100644 (file)
@@ -1,8 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <fcntl.h>
+#include <linux/prctl.h>
 #include <sched.h>
 #include <stdlib.h>
+#include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sysexits.h>
@@ -311,6 +313,10 @@ TEST(process_is_owned_by_uid) {
         if (r == 0) {
                 p[0] = safe_close(p[0]);
                 ASSERT_OK(fully_set_uid_gid(1, 1, NULL, 0));
+
+                /* After successfully changing id/gid DEATHSIG is reset, so it has to be set again */
+                ASSERT_OK_ERRNO(prctl(PR_SET_PDEATHSIG, SIGKILL));
+
                 ASSERT_OK_EQ_ERRNO(write(p[1], &(const char[]) { 'x' }, 1), 1);
                 p[1] = safe_close(p[1]);
                 freeze();
@@ -346,6 +352,9 @@ TEST(process_is_owned_by_uid) {
 
                 ASSERT_OK(reset_uid_gid());
 
+                /* After successfully changing id/gid DEATHSIG is reset, so it has to be set again */
+                ASSERT_OK_ERRNO(prctl(PR_SET_PDEATHSIG, SIGKILL));
+
                 ASSERT_OK_EQ_ERRNO(write(p[1], &(const char[]) { 'x' }, 1), 1);
                 p[1] = safe_close(p[1]);
                 freeze();