Re: [PATCH v2 2/5] clone: add CLONE_PIDFD

From: Oleg Nesterov
Date: Thu Apr 18 2019 - 09:12:22 EST

On 04/18, Christian Brauner wrote:
> @@ -1674,13 +1729,14 @@ static __latent_entropy struct task_struct *copy_process(
> unsigned long clone_flags,
> unsigned long stack_start,
> unsigned long stack_size,
> + int __user *parent_tidptr,
> int __user *child_tidptr,
> struct pid *pid,
> int trace,
> unsigned long tls,
> int node)
> {
> - int retval;
> + int pidfd = -1, retval;

it seems that initialization is unneeded, but this is cosmetic.

I see no technical problems, feel free to add my reviewed-by.

But let me ask a couple of questions...

Why O_CLOEXEC? I am just curious, I do not really care.

Should we allow CLONE_THREAD | CLONE_PIDFD ?

Are you sure we will never need to extend this interface? If not, then perhaps it
make sense to add something like

unsigned long not_used_yet;
if (get_user(not_used_yet, parent_tidptr) ||
not_used_yet != 0)
return -EINVAL;

this way we can easily add more arguments in future or even turn CLONE_PIDFD into

Not that I think this is really good idea, sys_clone2() makes more sense, but still.