Linux Test Project
 help / color / mirror / Atom feed
* [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
  2026-06-15  9:42 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2026-06-15  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12  9:58 [LTP] [PATCH v2] clone11: skip CLONE_NEWCGROUP on kernels < 4.6 Andrea Cervesato
2026-06-12 12:22 ` [LTP] " linuxtestproject.agent
2026-06-15  9:42 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox