Re: [PATCH v10 1/2] fork: extend clone3() to support setting a PID
From: Oleg Nesterov
Date: Thu Nov 14 2019 - 10:51:03 EST
On 11/14, Adrian Reber wrote:
>
> @@ -2600,6 +2602,15 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
> if (err)
> return err;
>
> + if (unlikely(args.set_tid_size > MAX_PID_NS_LEVEL))
> + return -EINVAL;
so we need this to because copy_from_user() below writes into the
set_tid[MAX_PID_NS_LEVEL] on the caller's stack, then later alloc_pid()
does another "correct" check... We could simply shift that check here,
but probably this would be less clear, so I won't argue.
> @@ -2617,8 +2628,16 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
> .stack = args.stack,
> .stack_size = args.stack_size,
> .tls = args.tls,
> + .set_tid_size = args.set_tid_size,
> };
...
> + kargs->set_tid = kset_tid;
this looks a bit strange, you could simply do
.set_tid_size = args.set_tid_size,
.set_tid = kset_tid,
but this is really minor.
Looks good to me,
Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>