[LTP] [PATCH] pidns32: fix PID namespace nesting depth off-by-one

Vasileios Almpanis vasileios.almpanis@virtuozzo.com
Mon Mar 30 12:07:44 CEST 2026


The 2023 refactor used tst_atomic_inc() before clone with a zero-initial
counter, which only performed 31 CLONE_NEWPID nests while still expecting
MAXNEST (32). Compare the level to MAXNEST first, then increment and clone,
so the shared counter runs 0..32 and the chain reaches 32 nested namespaces
again.

Fixes: 647cfd468c3b ("Refactor pidns32 test using new LTP API")
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
 testcases/kernel/containers/pidns/pidns32.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/pidns/pidns32.c b/testcases/kernel/containers/pidns/pidns32.c
index fc9bf0aaa..3a272f569 100644
--- a/testcases/kernel/containers/pidns/pidns32.c
+++ b/testcases/kernel/containers/pidns/pidns32.c
@@ -27,9 +27,11 @@ static pid_t child_func(void)
 {
 	pid_t cpid = 0;
 
-	if (tst_atomic_inc(level) == MAXNEST)
+	if (tst_atomic_load(level) == MAXNEST)
 		return cpid;
 
+	tst_atomic_inc(level);
+
 	cpid = SAFE_CLONE(&args);
 	if (!cpid) {
 		child_func();
-- 
2.43.0



More information about the ltp mailing list