Skip to content

Commit 1e396a5

Browse files
committed
Merge tag 'threads-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux
Pull thread updates from Christian Brauner: "The main change for this cycle was the extension for clone3() to support spawning processes directly into cgroups via CLONE_INTO_CGROUP (commit ef2c41c: "clone3: allow spawning processes into cgroups"). But since I had to touch kernel/cgroup/ quite a bit I had Tejun route that through his tree this time around to make it easier for him to handle other changes. So here is just the unexciting leftovers: a regression test for the ENOMEM regression we fixed in commit b26ebfe ("pid: Fix error return value in some cases") verifying that we report ENOMEM when trying to create a new process in a pid namespace whose init process/subreaper has already exited" * tag 'threads-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: selftests: add pid namespace ENOMEM regression test
2 parents 2fb732b + 6952a4f commit 1e396a5

File tree

7 files changed

+60
-0
lines changed

7 files changed

+60
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13285,6 +13285,7 @@ S: Maintained
1328513285
T: git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
1328613286
F: samples/pidfd/
1328713287
F: tools/testing/selftests/pidfd/
13288+
F: tools/testing/selftests/pid_namespace/
1328813289
F: tools/testing/selftests/clone3/
1328913290
K: (?i)pidfd
1329013291
K: (?i)clone3

tools/testing/selftests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ TARGETS += net/mptcp
3838
TARGETS += netfilter
3939
TARGETS += nsfs
4040
TARGETS += pidfd
41+
TARGETS += pid_namespace
4142
TARGETS += powerpc
4243
TARGETS += proc
4344
TARGETS += pstore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
regression_enomem
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
CFLAGS += -g -I../../../../usr/include/
3+
4+
TEST_GEN_PROGS := regression_enomem
5+
6+
include ../lib.mk
7+
8+
$(OUTPUT)/regression_enomem: regression_enomem.c ../pidfd/pidfd.h
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PID_NS=y
2+
CONFIG_USER_NS=y
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#define _GNU_SOURCE
2+
#include <assert.h>
3+
#include <errno.h>
4+
#include <fcntl.h>
5+
#include <linux/types.h>
6+
#include <sched.h>
7+
#include <signal.h>
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
#include <string.h>
11+
#include <syscall.h>
12+
#include <sys/wait.h>
13+
14+
#include "../kselftest.h"
15+
#include "../kselftest_harness.h"
16+
#include "../pidfd/pidfd.h"
17+
18+
/*
19+
* Regression test for:
20+
* 35f71bc0a09a ("fork: report pid reservation failure properly")
21+
* b26ebfe12f34 ("pid: Fix error return value in some cases")
22+
*/
23+
TEST(regression_enomem)
24+
{
25+
pid_t pid;
26+
27+
if (geteuid())
28+
EXPECT_EQ(0, unshare(CLONE_NEWUSER));
29+
30+
EXPECT_EQ(0, unshare(CLONE_NEWPID));
31+
32+
pid = fork();
33+
ASSERT_GE(pid, 0);
34+
35+
if (pid == 0)
36+
exit(EXIT_SUCCESS);
37+
38+
EXPECT_EQ(0, wait_for_pid(pid));
39+
40+
pid = fork();
41+
ASSERT_LT(pid, 0);
42+
ASSERT_EQ(errno, ENOMEM);
43+
}
44+
45+
TEST_HARNESS_MAIN

tools/testing/selftests/pidfd/pidfd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <string.h>
1414
#include <syscall.h>
1515
#include <sys/mount.h>
16+
#include <sys/types.h>
17+
#include <sys/wait.h>
1618

1719
#include "../kselftest.h"
1820

0 commit comments

Comments
 (0)