Skip to content

Commit a019ff3

Browse files
avaginChristian Brauner
authored andcommitted
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>
1 parent 28df751 commit a019ff3

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tools/testing/selftests/clone3/clone3_set_tid.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
160160
ksft_exit_fail_msg("pipe() failed\n");
161161

162162
ksft_print_header();
163-
ksft_set_plan(27);
163+
ksft_set_plan(29);
164164

165165
f = fopen("/proc/sys/kernel/pid_max", "r");
166166
if (f == NULL)
@@ -290,6 +290,18 @@ int main(int argc, char *argv[])
290290
/* Let's create a PID 1 */
291291
ns_pid = fork();
292292
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+
293305
ksft_print_msg("Child in PID namespace has PID %d\n", getpid());
294306
set_tid[0] = 2;
295307
test_clone3_set_tid(set_tid, 1, 0, 0, 2, 0);
@@ -366,7 +378,7 @@ int main(int argc, char *argv[])
366378
if (!WIFEXITED(status))
367379
ksft_test_result_fail("Child error\n");
368380

369-
ksft_cnt.ksft_pass += 4 - (ksft_cnt.ksft_fail - WEXITSTATUS(status));
381+
ksft_cnt.ksft_pass += 6 - (ksft_cnt.ksft_fail - WEXITSTATUS(status));
370382
ksft_cnt.ksft_fail = WEXITSTATUS(status);
371383

372384
if (ns3 == pid && ns2 == 42 && ns1 == 1)

0 commit comments

Comments
 (0)