lkml.org 
[lkml]   [2009]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC][v8][PATCH 0/10] Implement clone3() system call
From
Date
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> writes:

> Eric W. Biederman [ebiederm@xmission.com] wrote:
> | > | + if (target < RESERVED_PIDS)
> | >
> | > Should we replace RESERVED_PIDS with 0 ? We currently allow new
> | > containers to have pids 1..32K in the first pass and in subsequent
> | > passes assign starting at RESERVED_PIDS.
> |
> | If it is a preexisting namespace pid namespace removing the RESERVED_PIDS
> | check removes most if not all of the point of RESERVED_PIDS.
> |
> | In a new fresh pid namespace I have no problem with not performing
> | the RESERVED_PIDS check.
>
> In that case can we do this
>
> if (target_pid < RESERVED_PIDS && !pid_ns->level)
> return -EINVAL;
>
> instead ?
> |
> | So I guess that makes the check.
> |
> | if ((target < RESERVED_PIDS) && pid_ns->last_pid >= RESERVED_PIDS)
> | return -EINVAL;
>
> I am just wondering if there is a small corner case where C/R would randomly
> fail because of this sequence:
>
> - C/R code calls clone() or clone3() say about RESERVED_PIDS-1
> times and ->last_pid == RESERVED_PIDS-1.
>
> - C/R code calls normal fork()/alloc_pidmap() for a short-lived
> child - its pid == ->last_pid == RESERVED_PIDS
>
> - C/R code then calls clone3()/set_pidmap() to set the pid of
> a new child to RESERVED_PID but fails (i.e it fails to restore
> a pid even when the pid is not in use).
>
> We could argue that mixing alloc_pidmap() and set_pidmap() during restart
> is bad since set_pidmap() may fail.
>
> The C/R developer could argue that we are forcing them to specify a pid
> even for a short lived process that they wait()s on and thus ensure that
> pid is not in use.
>
> Anyway, is RESERVED_PIDS meant for initial kernel-threads/daemons - if so
> would it be ok enforce it only in init_pid_ns ?

It is mean for initial user space daemons, things that start on boot.

I don't know how much the protection matters at this date, but we have it.

Eric


\
 
 \ /
  Last update: 2009-10-23 07:47    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site