[LTP] [PATCH v1] clone302: Fix short size test
Wei Gao
wegao@suse.com
Sat Sep 2 07:56:38 CEST 2023
---
include/lapi/sched.h | 4 ++++
testcases/kernel/syscalls/clone3/clone302.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index ac766efc5..f1133ca12 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -46,6 +46,10 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
}
#ifndef HAVE_CLONE3
+
+#define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
+#define CLONE_ARGS_SIZE_VER2 88 /* sizeof third published struct */
+
struct clone_args {
uint64_t __attribute__((aligned(8))) flags;
uint64_t __attribute__((aligned(8))) pidfd;
diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
index b1b4ccebb..02ccb3c29 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -34,7 +34,8 @@ 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, CLONE_ARGS_SIZE_VER0 - 1, 0, NULL, SIGCHLD, 0, 0, 0, EINVAL},
+ {"short size for clone_into_group flag", &valid_args, CLONE_ARGS_SIZE_VER2 - 1, CLONE_INTO_CGROUP, 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},
--
2.35.3
More information about the ltp
mailing list