lkml.org 
[lkml]   [2019]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 1/2] fork: extend clone3() to support setting a PID
On Fri, Nov 15, 2019 at 11:49:10AM +0100, Oleg Nesterov wrote:
> On 11/15, Christian Brauner wrote:
> >
> > +static int set_tid_next(pid_t *set_tid, size_t *size, int idx)
> > +{
> > + int tid = 0;
> > +
> > + if (*size) {
> > + tid = set_tid[idx];
> > + if (tid < 1 || tid >= pid_max)
> > + return -EINVAL;
> > +
> > + /*
> > + * Also fail if a PID != 1 is requested and
> > + * no PID 1 exists.
> > + */
> > + if (tid != 1 && !tmp->child_reaper)
> > + return -EINVAL;
> > +
> > + if (!ns_capable(tmp->user_ns, CAP_SYS_ADMIN))
> > + return -EPERM;
> > +
> > + (*size)--;
> > + }
>
> this needs more args, struct pid_namespace *tmp + pid_t pid_max
> if (set_tid_size) {
> tid = set_tid[ns->level - i];
>
> retval = -EINVAL;
> if (tid < 1 || tid >= pid_max)
> goto out_free;

I'm not a fan of this pattern of _not_ setting error codes in the actual
error path t but I won't object.

Christian

\
 
 \ /
  Last update: 2019-11-15 14:09    [W:0.067 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site