This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v1 2/4] clone3: switch to copy_struct_from_user()
- From: Christian Brauner <christian dot brauner at ubuntu dot com>
- To: Aleksa Sarai <cyphar at cyphar dot com>
- Cc: Ingo Molnar <mingo at redhat dot com>, Peter Zijlstra <peterz at infradead dot org>, Alexander Shishkin <alexander dot shishkin at linux dot intel dot com>, Jiri Olsa <jolsa at redhat dot com>, Namhyung Kim <namhyung at kernel dot org>, Rasmus Villemoes <linux at rasmusvillemoes dot dk>, Al Viro <viro at zeniv dot linux dot org dot uk>, Linus Torvalds <torvalds at linux-foundation dot org>, libc-alpha at sourceware dot org, linux-api at vger dot kernel dot org, linux-kernel at vger dot kernel dot org
- Date: Wed, 25 Sep 2019 19:22:21 +0200
- Subject: Re: [PATCH v1 2/4] clone3: switch to copy_struct_from_user()
- References: <20190925165915.8135-1-cyphar@cyphar.com> <20190925165915.8135-3-cyphar@cyphar.com>
On Wed, Sep 25, 2019 at 06:59:13PM +0200, Aleksa Sarai wrote:
> The change is very straightforward, and helps unify the syscall
> interface for struct-from-userspace syscalls. Additionally, explicitly
> define CLONE_ARGS_SIZE_VER0 to match the other users of the
> struct-extension pattern.
>
> Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
> ---
> include/uapi/linux/sched.h | 2 ++
> kernel/fork.c | 34 +++++++---------------------------
> 2 files changed, 9 insertions(+), 27 deletions(-)
>
> diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h
> index b3105ac1381a..0945805982b4 100644
> --- a/include/uapi/linux/sched.h
> +++ b/include/uapi/linux/sched.h
> @@ -47,6 +47,8 @@ struct clone_args {
> __aligned_u64 tls;
> };
>
> +#define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
> +
> /*
> * Scheduling policies
> */
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 541fd805fb88..a86e3841ee4e 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -2530,39 +2530,19 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
> #ifdef __ARCH_WANT_SYS_CLONE3
> noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
> struct clone_args __user *uargs,
> - size_t size)
> + size_t usize)
> {
> + int err;
> struct clone_args args;
>
> - if (unlikely(size > PAGE_SIZE))
> + if (unlikely(usize > PAGE_SIZE))
> return -E2BIG;
> -
> - if (unlikely(size < sizeof(struct clone_args)))
> + if (unlikely(usize < CLONE_ARGS_SIZE_VER0))
> return -EINVAL;
You might want to rebase this patchset after the merge window closes on
rc1 since that code has changed right before the 5.3 release. But if you
can't don't worry I can also fix it up.
Christian