From: Chris Wailes via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] Update clone3 wrapper signature
Date: Fri, 20 Mar 2026 11:39:07 -0700 [thread overview]
Message-ID: <20260320183907.117127-1-chriswailes@google.com> (raw)
This CL adds the `ltp_clone3_raw` wrapper for direct testing of the
syscall and adds a `ltp_clone3` wrapper for libc implementations that
provide `clone3`.
Signed-off-by: Chris Wailes <chriswailes@google.com>
---
Notes:
V2: Added HAVE_STRUCT_CLONE_ARGS and updated clone304.c
configure.ac | 1 +
include/lapi/sched.h | 27 +++++++++++++++------
testcases/kernel/syscalls/clone3/clone301.c | 2 +-
testcases/kernel/syscalls/clone3/clone302.c | 2 +-
testcases/kernel/syscalls/clone3/clone304.c | 2 +-
5 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 043640240..d753df6f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -189,6 +189,7 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[
AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>])
AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>])
+AC_CHECK_TYPES([struct clone_args],,,[#include <sched.h>])
AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error,
struct fanotify_event_info_header, struct fanotify_event_info_pidfd,
struct fanotify_event_info_range],,,[#include <sys/fanotify.h>])
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 36f1ecad9..05b322c1c 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_STRUCT_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
+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 902e89091..668c1a225 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);
diff --git a/testcases/kernel/syscalls/clone3/clone304.c b/testcases/kernel/syscalls/clone3/clone304.c
index f0ef7d7e8..b91a081e5 100644
--- a/testcases/kernel/syscalls/clone3/clone304.c
+++ b/testcases/kernel/syscalls/clone3/clone304.c
@@ -58,7 +58,7 @@ static void run(unsigned int n)
args.set_tid_size = 1;
}
- TST_EXP_FAIL(clone3(&args, sizeof(args)), EPERM,
+ TST_EXP_FAIL(ltp_clone3_raw(&args, sizeof(args)), EPERM,
"clone3(%s) set_tid_size=%ld",
tc->sflags, args.set_tid_size);
}
--
2.53.0.959.g497ff81fa9-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-03-20 18:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 18:39 Chris Wailes via ltp [this message]
2026-03-23 6:53 ` [LTP] [PATCH v2] Update clone3 wrapper signature Li Wang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260320183907.117127-1-chriswailes@google.com \
--to=ltp@lists.linux.it \
--cc=chriswailes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.