[LTP] [PATCH v5] clone302: Fix short size test

Wei Gao wegao@suse.com
Thu Sep 7 12:01:49 CEST 2023


Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/lapi/sched.h                        | 11 +++++++++++
 testcases/kernel/syscalls/clone3/clone302.c |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index ac766efc5..26fdb628d 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -60,6 +60,17 @@ struct clone_args {
 	uint64_t __attribute__((aligned(8))) cgroup;
 };
 
+struct clone_args_minimal {
+	uint64_t __attribute__((aligned(8))) flags;
+	uint64_t __attribute__((aligned(8))) pidfd;
+	uint64_t __attribute__((aligned(8))) child_tid;
+	uint64_t __attribute__((aligned(8))) parent_tid;
+	uint64_t __attribute__((aligned(8))) exit_signal;
+	uint64_t __attribute__((aligned(8))) stack;
+	uint64_t __attribute__((aligned(8))) stack_size;
+	uint64_t __attribute__((aligned(8))) tls;
+};
+
 static inline int clone3(struct clone_args *args, size_t size)
 {
 	return tst_syscall(__NR_clone3, args, size);
diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
index b1b4ccebb..48b831554 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -12,6 +12,7 @@
 #define _GNU_SOURCE
 
 #include <stdlib.h>
+#include <assert.h>
 
 #include "tst_test.h"
 #include "lapi/sched.h"
@@ -34,7 +35,7 @@ static struct tcase {
 } tcases[] = {
 	{"invalid args", &invalid_args, sizeof(*valid_args), 0, NULL, SIGCHLD, 0, 0, 0, EFAULT},
 	{"zero size", &valid_args, 0, 0, NULL, SIGCHLD, 0, 0, 0, EINVAL},
-	{"short size", &valid_args, sizeof(*valid_args) - 1, 0, NULL, SIGCHLD, 0, 0, 0, EINVAL},
+	{"short size", &valid_args, sizeof(struct clone_args_minimal) - 1, 0, NULL, SIGCHLD, 0, 0, 0, EINVAL},
 	{"extra size", &valid_args, sizeof(*valid_args) + 1, 0, NULL, SIGCHLD, 0, 0, 0, EFAULT},
 	{"sighand-no-VM", &valid_args, sizeof(*valid_args), CLONE_SIGHAND, NULL, SIGCHLD, 0, 0, 0, EINVAL},
 	{"thread-no-sighand", &valid_args, sizeof(*valid_args), CLONE_THREAD, NULL, SIGCHLD, 0, 0, 0, EINVAL},
@@ -59,6 +60,8 @@ static void setup(void)
 {
 	clone3_supported_by_kernel();
 
+	TST_EXP_EQ_SZ(sizeof(struct clone_args_minimal), 64);
+
 	void *p = tst_get_bad_addr(NULL);
 
 	invalid_args = p;
-- 
2.35.3



More information about the ltp mailing list