Update the signature for clone_args struct bringing in support for capabilities and re-visit relevant testcases to take into account struct's new published versions.
Signed-off-by: Beata Michalska beata.michalska@arm.com --- include/lapi/clone.h | 19 +++++++++++-------- testcases/kernel/syscalls/clone3/clone302.c | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/include/lapi/clone.h b/include/lapi/clone.h index 437d1376f..6ff5e618b 100644 --- a/include/lapi/clone.h +++ b/include/lapi/clone.h @@ -17,14 +17,17 @@
#ifndef HAVE_CLONE3 struct clone_args { - 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; + __aligned_u64 flags; + __kernel_aligned_uintptr_t pidfd; + __kernel_aligned_uintptr_t child_tid; + __kernel_aligned_uintptr_t parent_tid; + __aligned_u64 exit_signal; + __kernel_aligned_uintptr_t stack; + __aligned_u64 stack_size; + __kernel_aligned_uintptr_t tls; + __kernel_aligned_uintptr_t set_tid; + __aligned_u64 set_tid_size; + __aligned_u64 cgroup; };
static inline int clone3(struct clone_args *args, size_t size) diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c index 08d6417ce..b6d8698ef 100644 --- a/testcases/kernel/syscalls/clone3/clone302.c +++ b/testcases/kernel/syscalls/clone3/clone302.c @@ -16,6 +16,8 @@ #include "tst_test.h" #include "lapi/clone.h"
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + static struct clone_args *valid_args, *invalid_args; unsigned long stack; static int *invalid_address; @@ -34,7 +36,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, offsetof(struct clone_args, tls) - 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},
On 16/12/2022 17:46, Beata Michalska wrote:
Update the signature for clone_args struct bringing in support for capabilities and re-visit relevant testcases to take into account struct's new published versions.
Signed-off-by: Beata Michalska beata.michalska@arm.com
include/lapi/clone.h | 19 +++++++++++-------- testcases/kernel/syscalls/clone3/clone302.c | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/include/lapi/clone.h b/include/lapi/clone.h index 437d1376f..6ff5e618b 100644 --- a/include/lapi/clone.h +++ b/include/lapi/clone.h @@ -17,14 +17,17 @@ #ifndef HAVE_CLONE3 struct clone_args {
- 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;
- __aligned_u64 flags;
- __kernel_aligned_uintptr_t pidfd;
- __kernel_aligned_uintptr_t child_tid;
- __kernel_aligned_uintptr_t parent_tid;
- __aligned_u64 exit_signal;
- __kernel_aligned_uintptr_t stack;
- __aligned_u64 stack_size;
- __kernel_aligned_uintptr_t tls;
- __kernel_aligned_uintptr_t set_tid;
- __aligned_u64 set_tid_size;
- __aligned_u64 cgroup;
}; static inline int clone3(struct clone_args *args, size_t size) diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c index 08d6417ce..b6d8698ef 100644 --- a/testcases/kernel/syscalls/clone3/clone302.c +++ b/testcases/kernel/syscalls/clone3/clone302.c @@ -16,6 +16,8 @@ #include "tst_test.h" #include "lapi/clone.h" +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
This is defined in <stddef.h>, might as well include it instead. I can see that the ptrace0* tests do that for instance. I have no idea why realtime/include/list.h defines it itself, that sounds like a bad idea for something normally provided by libc.
LGTM otherwise.
Kevin
static struct clone_args *valid_args, *invalid_args; unsigned long stack; static int *invalid_address; @@ -34,7 +36,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, offsetof(struct clone_args, tls) - 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},
linux-morello-ltp@op-lists.linaro.org