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

Richard Palethorpe rpalethorpe@suse.de
Tue Sep 5 10:40:32 CEST 2023


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.


More information about the ltp mailing list