[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b57e809d-e5fa-bda2-ee81-e86116bb2856@gmail.com>
Date: Wed, 7 Aug 2019 16:57:08 +0100
From: Dmitry Safonov <0x7f454c46@...il.com>
To: Oleg Nesterov <oleg@...hat.com>, Adrian Reber <areber@...hat.com>
Cc: Christian Brauner <christian@...uner.io>,
Eric Biederman <ebiederm@...ssion.com>,
Pavel Emelianov <xemul@...tuozzo.com>,
Jann Horn <jannh@...gle.com>, linux-kernel@...r.kernel.org,
Andrei Vagin <avagin@...il.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
Radostin Stoyanov <rstoyanov1@...il.com>
Subject: Re: [PATCH v3 1/2] fork: extend clone3() to support CLONE_SET_TID
On 8/7/19 4:48 PM, Oleg Nesterov wrote:
> On 08/06, Adrian Reber wrote:
>>
>> @@ -2530,12 +2530,14 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
>> struct clone_args __user *uargs,
>> size_t size)
>> {
>> + struct pid_namespace *pid_ns = task_active_pid_ns(current);
>> struct clone_args args;
>>
>> if (unlikely(size > PAGE_SIZE))
>> return -E2BIG;
>>
>> - if (unlikely(size < sizeof(struct clone_args)))
>> + /* The struct needs to be at least the size of the original struct. */
>> + if (size < (sizeof(struct clone_args) - sizeof(__aligned_u64)))
>> return -EINVAL;
>
> slightly off-topic, but with or without this patch I do not understand
> -EINVAL. Can't we replace this check with
>
> if (size < sizeof(struct clone_args))
> memset((void*)&args + size, sizeof(struct clone_args) - size, 0);
>
> ?
>
> this way we can new members at the end of clone_args and this matches
> the "if (size > sizeof(struct clone_args))" block below which promises
> that whatever we add into clone_args a zero value should work.
What if the size is lesser than offsetof(struct clone_args, stack_size)?
Probably, there should be still a check that it's not lesser than what's
the required minimum..
Also note, that (kargs) and (args) are a bit different beasts in this
context..
kargs lies on the stack and might want to be with zero-initializer
: struct kernel_clone_args kargs = {};
--
Dmitry
Powered by blists - more mailing lists