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

Petr Vorel pvorel@suse.cz
Thu Apr 2 22:55:34 CEST 2026


From: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

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). Use tst_atomic_return_add() so the shared counter runs
0..32 and the chain reaches 32 nested namespaces again.

Fixes: 647cfd468c3b ("Refactor pidns32 test using new LTP API")
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
[ pvorel: use tst_atomic_return_add() ]
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
v1: https://lore.kernel.org/ltp/20260330100750.858390-1-vasileios.almpanis@virtuozzo.com/

 testcases/kernel/containers/pidns/pidns32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/containers/pidns/pidns32.c b/testcases/kernel/containers/pidns/pidns32.c
index fc9bf0aaa0..2a9e2827fc 100644
--- a/testcases/kernel/containers/pidns/pidns32.c
+++ b/testcases/kernel/containers/pidns/pidns32.c
@@ -27,7 +27,7 @@ static pid_t child_func(void)
 {
 	pid_t cpid = 0;
 
-	if (tst_atomic_inc(level) == MAXNEST)
+	if (tst_atomic_return_add(1, level) == MAXNEST)
 		return cpid;
 
 	cpid = SAFE_CLONE(&args);
@@ -58,7 +58,7 @@ static void run(void)
 	if (!child_func())
 		return;
 
-	TST_EXP_EQ_LI(*level, MAXNEST);
+	TST_EXP_EQ_LI(*level-1, MAXNEST);
 }
 
 static struct tst_test test = {
-- 
2.53.0



More information about the ltp mailing list