clone302: Fix short size test
PATCH 1/1 clone302: Fix short size test
--- include/lapi/sched.h | 4 ++++ testcases/kernel/syscalls/clone3/clone302.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
include/lapi/sched.h +4 -0
@@ -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;
testcases/kernel/syscalls/clone3/clone302.c +2 -1
@@ -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},
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 clone302: Fix short size test
--- include/lapi/sched.h | 4 ++++ testcases/kernel/syscalls/clone3/clone302.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
include/lapi/sched.h +4 -0
@@ -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;
testcases/kernel/syscalls/clone3/clone302.c +2 -1
@@ -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},
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 11 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 4 ++++ testcases/kernel/syscalls/clone3/clone302.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)include/lapi/sched.h +0
-0
include/lapi/sched.h static inline int sched_getattr(pid_t pid, struct sched_attr *attr, · line 50
Quoted 5 lines
include/lapi/sched.h +2
-0@@ -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 */
I think what Martin meant was to define a minimal struct, which I prefer for a few reasons.
You can find the original def in commit:7f192e3cd316ba58c88dfa26796cf77789dd9872
(I found that using Git blame on fork.c)
Then you can assert our struct is == 64 during the test. This is paranoid, but it checks that the test is compiled correctly and we defined the structure correctly.
Quoted 21 lines
include/lapi/sched.h +2
-0+#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;testcases/kernel/syscalls/clone3/clone302.c +2
-1@@ -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},Signature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 clone302: Fix short size test
In reply to Wei Gao via ltp--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
include/lapi/sched.h +11 -0
@@ -60,6 +60,17 @@ struct clone_args {uint64_t __attribute__((aligned (8 ))) cgroup; }; +struct clone_args_minimal { +__aligned_u64 flags; +__aligned_u64 pidfd; +__aligned_u64 child_tid; +__aligned_u64 parent_tid; +__aligned_u64 exit_signal; +__aligned_u64 stack; +__aligned_u64 stack_size; +__aligned_u64 tls; +}; +static inline int clone3 (struct clone_args *args,size_t size) {return tst_syscall (__NR_clone3, args, size);
testcases/kernel/syscalls/clone3/clone302.c +1 -1
@@ -34,7 +34,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},
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 14 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)include/lapi/sched.h +0
-0@@ -60,6 +60,17 @@ struct clone_args {uint64_t __attribute__((aligned (8 ))) cgroup; };
include/lapi/sched.h struct clone_args { · line 72
Quoted 10 lines
include/lapi/sched.h +10
-0+struct clone_args_minimal { +__aligned_u64 flags; +__aligned_u64 pidfd; +__aligned_u64 child_tid; +__aligned_u64 parent_tid; +__aligned_u64 exit_signal; +__aligned_u64 stack; +__aligned_u64 stack_size; +__aligned_u64 tls; +};
These look like kernel types. We have to write uint64_t __attribute__((aligned(8))) or do our own type def of that.
Also I did say to assert during setup that clone_args_minimal is 64 bytes as expected.
Quoted 19 lines
include/lapi/sched.h +1
-0+static inline int clone3 (struct clone_args *args,size_t size) {return tst_syscall (__NR_clone3, args, size);testcases/kernel/syscalls/clone3/clone302.c +1
-1@@ -34,7 +34,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},Signature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/1 clone302: Fix short size test
In reply to Wei Gao via ltp--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-)
include/lapi/sched.h +11 -0
@@ -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);
testcases/kernel/syscalls/clone3/clone302.c +4 -1
@@ -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 (); +assert (sizeof (struct clone_args_minimal ) ==64 ); +void *p =tst_get_bad_addr (NULL ); invalid_args = p;
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 50 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-)include/lapi/sched.h +11
-0@@ -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);testcases/kernel/syscalls/clone3/clone302.c +2
-1@@ -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},
testcases/kernel/syscalls/clone3/clone302.c static void setup(void) · line 63
Quoted 4 lines
testcases/kernel/syscalls/clone3/clone302.c +1
-0@@ -59,6 +60,8 @@ static void setup(void) {clone3_supported_by_kernel (); +assert (sizeof (struct clone_args_minimal ) ==64 );
Sorry I mean with TST_EXP_EQ_SZ or just an if statement followed by tst_brk. The stdlib assert macro will produce a signal on failure and it will look messy.
Quoted 6 lines
testcases/kernel/syscalls/clone3/clone302.c +1
-0+void *p =tst_get_bad_addr (NULL ); invalid_args = p;Signature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/1 clone302: Fix short size test
In reply to Wei Gao via ltp--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-)
include/lapi/sched.h +11 -0
@@ -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);
testcases/kernel/syscalls/clone3/clone302.c +4 -1
@@ -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;
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Pushed!
Quoted 60 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 11 +++++++++++ testcases/kernel/syscalls/clone3/clone302.c | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-)include/lapi/sched.h +11
-0@@ -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);testcases/kernel/syscalls/clone3/clone302.c +4
-1@@ -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;Signature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp