From aece4b0381a339bd36faf46cd99789251201be90 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 10 Sep 2025 00:32:02 +0100 Subject: [PATCH 1/2] test: do not leave process hanging in test-namespace It is killed when the main test process exists, but still, it will be left hanging while other test cases run, so it's not very clean. Follow-up for 8b5e3be88eeb1bdba50c87cb24d9e6b31e825f38 --- src/test/test-namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index 4b12e020e2..79c9431088 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -425,7 +425,7 @@ TEST(namespace_get_leader) { } TEST(detach_mount_namespace_harder) { - _cleanup_(pidref_done) PidRef pid = PIDREF_NULL; + _cleanup_(pidref_done_sigkill_wait) PidRef pid = PIDREF_NULL; _cleanup_close_pair_ int p[2] = EBADF_PAIR; char x = 0; int r; From 15818468f8b152657aa2be41282868017371cfc1 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 11 Sep 2025 13:16:26 +0100 Subject: [PATCH 2/2] test: PR_DEATHSIG is reset after changing id/gid 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index 79c9431088..83d47d62b0 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #include #include +#include #include #include #include @@ -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();