[Devel] Re: [RFC][v3][PATCH 7/7] Define clone_with_pids syscall

Oren Laadan orenl at cs.columbia.edu
Mon Jun 1 12:35:02 PDT 2009



Serge E. Hallyn wrote:
> Quoting Oren Laadan (orenl at cs.columbia.edu):
>>> One last thought - should there be an explicit check to make sure that
>>> if CLONE_NEWPID, then at the end pid[knum_pids+1] = 0?  Or is that
>>> there and I just missed it?
>> the wonders of kzalloc() ...
> 
> No.  I'm saying that I don't see anything stopping the user from
> doing CLONE_NEWPID while specifying an extra pid, so that they
> end up trying to create a pidns init with vpid 5

The last slot in the array is always zero. The size of the array
is parent's nesting level + 2 (one for counting from zero, and
one for the new pidns, if any).

In your example, the parent is in level 2, so the array is of
size 4. The parent should provide an array of size 2, and then
clone_with_pid() will attempt to set pids of the child at levels
1 and 2 (level 0 is set by the kernel).

If however the parent gives an array of size 3, clone_with_pid()
will try to set pids of the child at level 0, 1 and 2 instead.
level 3 is below the parent, and will always use the last slot
in the (kernel) array.

Finally, for an array of size 4, clone_with_pid() will return
an error.

Did I entirely misread your question ?

Oren.
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list