]> git.hungrycats.org Git - linux/commit
selftests/namespaces: Fix waitpid race in listns_efault_test cleanup
authorRicardo B. Marlière <rbm@suse.com>
Tue, 7 Apr 2026 14:35:46 +0000 (11:35 -0300)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 10:25:32 +0000 (12:25 +0200)
commitf36ddf9317dc99019a498af3853d547de1f62e5f
tree3e2c44e57d0728f86ff5948521722efcf484389d
parentfdb48976b6379c2b91e1ad4aafef07ee8b1ddb0e
selftests/namespaces: Fix waitpid race in listns_efault_test cleanup

The efault tests spawn two categories of child processes: namespace
children (each in its own mount namespace, for concurrent destruction) and
an iterator child that calls listns() in a tight loop.  The cleanup loop
used waitpid(-1), which reaps any child in any order. If the iterator child
exits early (e.g. because listns() returned ENOSYS) before all namespace
children have been reaped, waitpid(-1) may consume it instead.  The
subsequent targeted waitpid(iter_pid) would then block indefinitely.

Track the PIDs of the namespace children explicitly and use targeted
waitpid() calls in the cleanup loop so the iterator child cannot be
inadvertently reaped during namespace cleanup.

Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
Link: https://patch.msgid.link/20260407-selftests-namespaces_fixes-v1-2-59109909d88b@suse.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
tools/testing/selftests/namespaces/listns_efault_test.c