Re: [PATCH v3 1/2] fork: extend clone3() to support CLONE_SET_TID

From: Dmitry Safonov
Date: Wed Aug 07 2019 - 12:47:44 EST


On 8/7/19 5:33 PM, Dmitry Safonov wrote:
> On 8/7/19 5:21 PM, Oleg Nesterov wrote:
>> On 08/07, Dmitry Safonov wrote:
> [..]
>>> 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..
>>
>> Not sure I understand... I mean, this doesn't differ from the case when
>> size == sizeof(clone_args) but uargs->stack == NULL ?
>
> I might be mistaken and I confess that I don't fully understand the
> code, but wouldn't it mystically fail in copy_thread_tls() with -ENOMEM
> instead of -EINVAL?
> Maybe not a huge difference, but..

Actually, not there. I've just tried clone3() with stack_size == 0, it
sets it a proper size somewhere on the way..
So, apologies for the misinformation - it seems that we definitely could
just memset() the missing fields.

Thanks,
Dmitry