public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] Update clone3 wrapper signature
@ 2025-11-14 19:52 Chris Wailes via ltp
  2025-12-16 12:40 ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2025-11-14 19:52 UTC (permalink / raw)
  To: ltp

From a932e9d3ee093933a5bd58edecec42a61df2b6c0 Mon Sep 17 00:00:00 2001
From: Chris Wailes <chriswailes@google.com>
Date: Fri, 14 Nov 2025 10:42:21 -0800
Subject: [PATCH] Update clone3 wrapper signature

This CL updates the clone3 wrapper and tests to match the function
signatures used by glibc (internally) and BIONIC (publicly).

Signed-off-by: Chris Wailes <chriswailes@google.com>
---
 include/lapi/sched.h                        | 2 +-
 testcases/kernel/syscalls/clone3/clone301.c | 2 +-
 testcases/kernel/syscalls/clone3/clone302.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 36f1ecad9..2fec8e397 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -75,7 +75,7 @@ struct clone_args_minimal {
  uint64_t __attribute__((aligned(8))) tls;
 };

-static inline int clone3(struct clone_args *args, size_t size)
+static inline int clone3(struct clone_args *args, size_t size, int
(*)(void*), void*)
 {
  return tst_syscall(__NR_clone3, args, size);
 }
diff --git a/testcases/kernel/syscalls/clone3/clone301.c
b/testcases/kernel/syscalls/clone3/clone301.c
index deed30b9f..ecd791389 100644
--- a/testcases/kernel/syscalls/clone3/clone301.c
+++ b/testcases/kernel/syscalls/clone3/clone301.c
@@ -123,7 +123,7 @@ static void run(unsigned int n)
  parent_received_signal = 0;
  SAFE_SIGACTION(tc->exit_signal, &psig_action, NULL);

- TEST(pid = clone3(args, sizeof(*args)));
+ TEST(pid = clone3(args, sizeof(*args), NULL, NULL));
  if (pid < 0) {
  tst_res(TFAIL | TTERRNO, "clone3() failed (%d)", n);
  return;
diff --git a/testcases/kernel/syscalls/clone3/clone302.c
b/testcases/kernel/syscalls/clone3/clone302.c
index 9e98f1954..e241be7cd 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -83,7 +83,7 @@ static void run(unsigned int n)
  args->tls = tc->tls;
  }

- TEST(clone3(args, tc->size));
+ TEST(clone3(args, tc->size, NULL, NULL));

  if (!TST_RET)
  exit(EXIT_SUCCESS);
-- 
2.52.0.rc1.455.g30608eb744-goog

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [LTP] [PATCH] Update clone3 wrapper signature
@ 2026-03-19 18:54 Chris Wailes via ltp
  2026-03-20  3:13 ` Li Wang via ltp
  0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2026-03-19 18:54 UTC (permalink / raw)
  To: ltp

This CL adds the `ltp_clone3_raw` wrapper for direct testing of the
syscall, conditionally defines `clone_args_minimal`, and adds a
`ltp_clone3` wrapper for libc implementations that provide `clone3`.
---
 include/lapi/sched.h                        | 27 +++++++++++++++------
 testcases/kernel/syscalls/clone3/clone301.c |  2 +-
 testcases/kernel/syscalls/clone3/clone302.c |  2 +-
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 36f1ecad9..fc367f772 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -49,8 +49,7 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
 # define SCHED_ATTR_SIZE_VER0 48	/* sizeof first published struct */
 #endif
 
-#ifndef HAVE_CLONE3
-struct clone_args {
+struct clone_args_minimal {
 	uint64_t __attribute__((aligned(8))) flags;
 	uint64_t __attribute__((aligned(8))) pidfd;
 	uint64_t __attribute__((aligned(8))) child_tid;
@@ -59,12 +58,10 @@ struct clone_args {
 	uint64_t __attribute__((aligned(8))) stack;
 	uint64_t __attribute__((aligned(8))) stack_size;
 	uint64_t __attribute__((aligned(8))) tls;
-	uint64_t __attribute__((aligned(8))) set_tid;
-	uint64_t __attribute__((aligned(8))) set_tid_size;
-	uint64_t __attribute__((aligned(8))) cgroup;
 };
 
-struct clone_args_minimal {
+#ifndef HAVE_CLONE_ARGS
+struct clone_args {
 	uint64_t __attribute__((aligned(8))) flags;
 	uint64_t __attribute__((aligned(8))) pidfd;
 	uint64_t __attribute__((aligned(8))) child_tid;
@@ -73,12 +70,28 @@ struct clone_args_minimal {
 	uint64_t __attribute__((aligned(8))) stack;
 	uint64_t __attribute__((aligned(8))) stack_size;
 	uint64_t __attribute__((aligned(8))) tls;
+	uint64_t __attribute__((aligned(8))) set_tid;
+	uint64_t __attribute__((aligned(8))) set_tid_size;
+	uint64_t __attribute__((aligned(8))) cgroup;
 };
+#endif
 
-static inline int clone3(struct clone_args *args, size_t size)
+static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
 {
 	return tst_syscall(__NR_clone3, args, size);
 }
+
+#ifdef HAVE_CLONE3_WRAPPER
+static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
+               int (*fn)(void *), void *arg) {
+	return clone3(cl_args, size, fn, arg);
+}
+#else
+static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
+                             int (*fn)(void *), void *arg)
+{
+	return -1;
+}
 #endif
 
 static inline void clone3_supported_by_kernel(void)
diff --git a/testcases/kernel/syscalls/clone3/clone301.c b/testcases/kernel/syscalls/clone3/clone301.c
index deed30b9f..58fc1702e 100644
--- a/testcases/kernel/syscalls/clone3/clone301.c
+++ b/testcases/kernel/syscalls/clone3/clone301.c
@@ -123,7 +123,7 @@ static void run(unsigned int n)
 	parent_received_signal = 0;
 	SAFE_SIGACTION(tc->exit_signal, &psig_action, NULL);
 
-	TEST(pid = clone3(args, sizeof(*args)));
+	TEST(pid = ltp_clone3_raw(args, sizeof(*args)));
 	if (pid < 0) {
 		tst_res(TFAIL | TTERRNO, "clone3() failed (%d)", n);
 		return;
diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
index 9e98f1954..883112183 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -83,7 +83,7 @@ static void run(unsigned int n)
 		args->tls = tc->tls;
 	}
 
-	TEST(clone3(args, tc->size));
+	TEST(ltp_clone3_raw(args, tc->size));
 
 	if (!TST_RET)
 		exit(EXIT_SUCCESS);
-- 
2.53.0.959.g497ff81fa9-goog


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

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

end of thread, other threads:[~2026-03-20  3:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 19:52 [LTP] [PATCH] Update clone3 wrapper signature Chris Wailes via ltp
2025-12-16 12:40 ` Andrea Cervesato via ltp
2025-12-16 17:50   ` Chris Wailes via ltp
2025-12-17  7:58     ` Anrea Cervesato via ltp
2025-12-17  9:43       ` Li Wang via ltp
2026-03-04 21:33         ` Chris Wailes via ltp
2026-03-18 18:29           ` Chris Wailes via ltp
2026-03-19  3:54             ` Li Wang via ltp
2026-03-19 18:55               ` Chris Wailes via ltp
  -- strict thread matches above, loose matches on Subject: below --
2026-03-19 18:54 Chris Wailes via ltp
2026-03-20  3:13 ` Li Wang via ltp

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