* [LTP] [PATCH v1] clone302: Fix short size test
@ 2023-09-02 5:56 Wei Gao via ltp
2023-09-02 7:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
0 siblings, 1 reply; 9+ messages in thread
From: Wei Gao via ltp @ 2023-09-02 5:56 UTC (permalink / raw)
To: ltp
---
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] clone302: Fix short size test
2023-09-02 5:56 [LTP] [PATCH v1] clone302: Fix short size test Wei Gao via ltp
@ 2023-09-02 7:47 ` Wei Gao via ltp
2023-09-04 7:48 ` Richard Palethorpe
2023-09-04 8:52 ` [LTP] [PATCH v3] " Wei Gao via ltp
0 siblings, 2 replies; 9+ messages in thread
From: Wei Gao via ltp @ 2023-09-02 7:47 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
---
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] clone302: Fix short size test
2023-09-02 7:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
@ 2023-09-04 7:48 ` Richard Palethorpe
2023-09-04 8:52 ` [LTP] [PATCH v3] " Wei Gao via ltp
1 sibling, 0 replies; 9+ messages in thread
From: Richard Palethorpe @ 2023-09-04 7:48 UTC (permalink / raw)
To: Wei Gao; +Cc: Martin Doucha, ltp
Hello,
Wei Gao via ltp <ltp@lists.linux.it> writes:
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> 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 */
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.
> +#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
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v3] clone302: Fix short size test
2023-09-02 7:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
2023-09-04 7:48 ` Richard Palethorpe
@ 2023-09-04 8:52 ` Wei Gao via ltp
2023-09-05 8:40 ` Richard Palethorpe
2023-09-05 10:14 ` [LTP] [PATCH v4] " Wei Gao via ltp
1 sibling, 2 replies; 9+ messages in thread
From: Wei Gao via ltp @ 2023-09-04 8:52 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
---
include/lapi/sched.h | 11 +++++++++++
testcases/kernel/syscalls/clone3/clone302.c | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index ac766efc5..f42b8969f 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 {
+ __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);
diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
index b1b4ccebb..bd1038319 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -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},
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v3] clone302: Fix short size test
2023-09-04 8:52 ` [LTP] [PATCH v3] " Wei Gao via ltp
@ 2023-09-05 8:40 ` Richard Palethorpe
2023-09-05 10:14 ` [LTP] [PATCH v4] " Wei Gao via ltp
1 sibling, 0 replies; 9+ messages in thread
From: Richard Palethorpe @ 2023-09-05 8:40 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hello,
Wei Gao via ltp <ltp@lists.linux.it> writes:
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> include/lapi/sched.h | 11 +++++++++++
> testcases/kernel/syscalls/clone3/clone302.c | 2 +-
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/include/lapi/sched.h b/include/lapi/sched.h
> index ac766efc5..f42b8969f 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 {
> + __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.
> +
> 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..bd1038319 100644
> --- a/testcases/kernel/syscalls/clone3/clone302.c
> +++ b/testcases/kernel/syscalls/clone3/clone302.c
> @@ -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},
> --
> 2.35.3
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v4] clone302: Fix short size test
2023-09-04 8:52 ` [LTP] [PATCH v3] " Wei Gao via ltp
2023-09-05 8:40 ` Richard Palethorpe
@ 2023-09-05 10:14 ` Wei Gao via ltp
2023-09-06 7:55 ` Richard Palethorpe
2023-09-07 10:01 ` [LTP] [PATCH v5] " Wei Gao via ltp
1 sibling, 2 replies; 9+ messages in thread
From: Wei Gao via ltp @ 2023-09-05 10:14 UTC (permalink / raw)
To: ltp
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..9cbf2d58e 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();
+ assert(sizeof(struct clone_args_minimal) == 64);
+
void *p = tst_get_bad_addr(NULL);
invalid_args = p;
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v4] clone302: Fix short size test
2023-09-05 10:14 ` [LTP] [PATCH v4] " Wei Gao via ltp
@ 2023-09-06 7:55 ` Richard Palethorpe
2023-09-07 10:01 ` [LTP] [PATCH v5] " Wei Gao via ltp
1 sibling, 0 replies; 9+ messages in thread
From: Richard Palethorpe @ 2023-09-06 7:55 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hello,
Wei Gao via ltp <ltp@lists.linux.it> writes:
> 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..9cbf2d58e 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();
>
> + 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.
> +
> void *p = tst_get_bad_addr(NULL);
>
> invalid_args = p;
> --
> 2.35.3
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v5] clone302: Fix short size test
2023-09-05 10:14 ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-09-06 7:55 ` Richard Palethorpe
@ 2023-09-07 10:01 ` Wei Gao via ltp
2023-09-07 11:11 ` Richard Palethorpe
1 sibling, 1 reply; 9+ messages in thread
From: Wei Gao via ltp @ 2023-09-07 10:01 UTC (permalink / raw)
To: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v5] clone302: Fix short size test
2023-09-07 10:01 ` [LTP] [PATCH v5] " Wei Gao via ltp
@ 2023-09-07 11:11 ` Richard Palethorpe
0 siblings, 0 replies; 9+ messages in thread
From: Richard Palethorpe @ 2023-09-07 11:11 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hello,
Pushed!
Wei Gao via ltp <ltp@lists.linux.it> writes:
> 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
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-09-07 11:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-02 5:56 [LTP] [PATCH v1] clone302: Fix short size test Wei Gao via ltp
2023-09-02 7:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
2023-09-04 7:48 ` Richard Palethorpe
2023-09-04 8:52 ` [LTP] [PATCH v3] " Wei Gao via ltp
2023-09-05 8:40 ` Richard Palethorpe
2023-09-05 10:14 ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-09-06 7:55 ` Richard Palethorpe
2023-09-07 10:01 ` [LTP] [PATCH v5] " Wei Gao via ltp
2023-09-07 11:11 ` Richard Palethorpe
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.