Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/clone3: check that all pids are released on error paths

This is a regression test case for an issue when pids have not been
released on error paths.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
Link: https://lore.kernel.org/r/20191118064750.408003-3-avagin@gmail.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

authored by

Andrei Vagin and committed by
Christian Brauner
a019ff3b 28df7515

+14 -2
+14 -2
tools/testing/selftests/clone3/clone3_set_tid.c
··· 160 160 ksft_exit_fail_msg("pipe() failed\n"); 161 161 162 162 ksft_print_header(); 163 - ksft_set_plan(27); 163 + ksft_set_plan(29); 164 164 165 165 f = fopen("/proc/sys/kernel/pid_max", "r"); 166 166 if (f == NULL) ··· 290 290 /* Let's create a PID 1 */ 291 291 ns_pid = fork(); 292 292 if (ns_pid == 0) { 293 + /* 294 + * This and the next test cases check that all pid-s are 295 + * released on error paths. 296 + */ 297 + set_tid[0] = 43; 298 + set_tid[1] = -1; 299 + test_clone3_set_tid(set_tid, 2, 0, -EINVAL, 0, 0); 300 + 301 + set_tid[0] = 43; 302 + set_tid[1] = pid; 303 + test_clone3_set_tid(set_tid, 2, 0, 0, 43, 0); 304 + 293 305 ksft_print_msg("Child in PID namespace has PID %d\n", getpid()); 294 306 set_tid[0] = 2; 295 307 test_clone3_set_tid(set_tid, 1, 0, 0, 2, 0); ··· 378 366 if (!WIFEXITED(status)) 379 367 ksft_test_result_fail("Child error\n"); 380 368 381 - ksft_cnt.ksft_pass += 4 - (ksft_cnt.ksft_fail - WEXITSTATUS(status)); 369 + ksft_cnt.ksft_pass += 6 - (ksft_cnt.ksft_fail - WEXITSTATUS(status)); 382 370 ksft_cnt.ksft_fail = WEXITSTATUS(status); 383 371 384 372 if (ns3 == pid && ns2 == 42 && ns1 == 1)