All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] clone11: skip CLONE_NEWCGROUP on kernels < 4.6
@ 2026-06-11 14:03 Andrea Cervesato
  2026-06-11 14:39 ` [LTP] " linuxtestproject.agent
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-06-11 14:03 UTC (permalink / raw)
  To: Linux Test Project

From: Andrea Cervesato <andrea.cervesato@suse.com>

CLONE_NEWCGROUP was added in kernel v4.6. On older kernels such as
v4.4, the flag is unknown and clone() returns EINVAL instead of the
expected EPERM, causing a spurious test failure.

Add a per-test-case minimum kernel version check so that the
CLONE_NEWCGROUP case reports TCONF on kernels older than 4.6.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/syscalls/clone/clone11.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/clone/clone11.c b/testcases/kernel/syscalls/clone/clone11.c
index 028da778158de6867a71ac3974f9c2263481d3a3..607e42585fad41784be9104be01f504218559342 100644
--- a/testcases/kernel/syscalls/clone/clone11.c
+++ b/testcases/kernel/syscalls/clone/clone11.c
@@ -21,9 +21,10 @@ static int *child_pid;
 static struct tcase {
 	uint64_t flags;
 	const char *sflags;
+	int min_kver[3];
 } tcases[] = {
 	{ DESC(CLONE_NEWPID) },
-	{ DESC(CLONE_NEWCGROUP) },
+	{ DESC(CLONE_NEWCGROUP), .min_kver = {4, 6, 0} },
 	{ DESC(CLONE_NEWIPC) },
 	{ DESC(CLONE_NEWNET) },
 	{ DESC(CLONE_NEWNS) },
@@ -40,6 +41,13 @@ static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
 
+	if (tc->min_kver[0] &&
+	    tst_kvercmp(tc->min_kver[0], tc->min_kver[1], tc->min_kver[2]) < 0) {
+		tst_res(TCONF, "clone(%s) needs kernel %d.%d+",
+			tc->sflags, tc->min_kver[0], tc->min_kver[1]);
+		return;
+	}
+
 	TST_EXP_FAIL(ltp_clone(tc->flags, child_fn, NULL, CHILD_STACK_SIZE, child_stack),
 		EPERM, "clone(%s) should fail with EPERM",
 		tc->sflags);

---
base-commit: a375e8deed471723f5a0114c56eb48fe6f6f45d3
change-id: 20260611-fix_clone11_min_kver-394cf499c2c7

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [LTP] [PATCH v2] clone11: skip CLONE_NEWCGROUP on kernels < 4.6
@ 2026-06-12  9:58 Andrea Cervesato
  2026-06-12 12:22 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Cervesato @ 2026-06-12  9:58 UTC (permalink / raw)
  To: Linux Test Project

From: Andrea Cervesato <andrea.cervesato@suse.com>

CLONE_NEWCGROUP was added in kernel v4.6. On older kernels such as
v4.4, the flag is unknown and clone() returns EINVAL instead of the
expected EPERM, causing a spurious test failure.

Add a per-test-case minimum kernel version check so that the
CLONE_NEWCGROUP case reports TCONF on kernels older than 4.6.

Reviewed-by: Avinesh Kumar <avinesh.kumar@suse.com>
Reviewed-by: Wei Gao <wegao@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v2:
- follow madvise02 pattern to recognize if test needs to be skipped
- Link to v1: https://lore.kernel.org/r/20260611-fix_clone11_min_kver-v1-1-264fba2b01b4@suse.com
---
 testcases/kernel/syscalls/clone/clone11.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/testcases/kernel/syscalls/clone/clone11.c b/testcases/kernel/syscalls/clone/clone11.c
index 028da778158de6867a71ac3974f9c2263481d3a3..98b36c8ec2ea51d9333fcd899cb1908e2839d851 100644
--- a/testcases/kernel/syscalls/clone/clone11.c
+++ b/testcases/kernel/syscalls/clone/clone11.c
@@ -21,6 +21,7 @@ static int *child_pid;
 static struct tcase {
 	uint64_t flags;
 	const char *sflags;
+	int skip;
 } tcases[] = {
 	{ DESC(CLONE_NEWPID) },
 	{ DESC(CLONE_NEWCGROUP) },
@@ -36,10 +37,33 @@ static int child_fn(void *arg LTP_ATTRIBUTE_UNUSED)
 	_exit(0);
 }
 
+static void tcases_filter(void)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
+		struct tcase *tc = &tcases[i];
+
+		switch (tc->flags) {
+		case CLONE_NEWCGROUP:
+			if (tst_kvercmp(4, 6, 0) < 0)
+				tc->skip = 1;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
 static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
 
+	if (tc->skip) {
+		tst_res(TCONF, "%s is not supported", tc->sflags);
+		return;
+	}
+
 	TST_EXP_FAIL(ltp_clone(tc->flags, child_fn, NULL, CHILD_STACK_SIZE, child_stack),
 		EPERM, "clone(%s) should fail with EPERM",
 		tc->sflags);
@@ -51,6 +75,8 @@ static void setup(void)
 			PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANONYMOUS,
 			-1, 0);
+
+	tcases_filter();
 }
 
 static void cleanup(void)

---
base-commit: a3fda1dc1ce7da882a592a4877da7f214e468650
change-id: 20260611-fix_clone11_min_kver-394cf499c2c7

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-12 12:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 14:03 [LTP] [PATCH] clone11: skip CLONE_NEWCGROUP on kernels < 4.6 Andrea Cervesato
2026-06-11 14:39 ` [LTP] " linuxtestproject.agent
2026-06-12  5:14 ` [LTP] [PATCH] " Avinesh Kumar via ltp
2026-06-12  8:31 ` Wei Gao via ltp
  -- strict thread matches above, loose matches on Subject: below --
2026-06-12  9:58 [LTP] [PATCH v2] " Andrea Cervesato
2026-06-12 12:22 ` [LTP] " linuxtestproject.agent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.