[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190730165538.GE18501@redhat.com>
Date: Tue, 30 Jul 2019 18:55:39 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Adrian Reber <areber@...hat.com>
Cc: Christian Brauner <christian@...uner.io>,
Eric Biederman <ebiederm@...ssion.com>,
Pavel Emelianov <xemul@...tuozzo.com>,
Jann Horn <jannh@...gle.com>, linux-kernel@...r.kernel.org,
Andrei Vagin <avagin@...il.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
Radostin Stoyanov <rstoyanov1@...il.com>
Subject: Re: [PATCH 1/2] fork: extend clone3() to support CLONE_SET_TID
On 07/29, Adrian Reber wrote:
>
> @@ -186,12 +187,26 @@ struct pid *alloc_pid(struct pid_namespace *ns)
> if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS)
> pid_min = RESERVED_PIDS;
>
> + if (set_tid) {
> + if ((set_tid >= pid_max) || ((set_tid != 1) &&
> + (idr_get_cursor(&tmp->idr) <= 1))) {
I think the
(set_tid != 1) && idr_get_cursor() <= 1
check needs a comment...
> + spin_unlock_irq(&pidmap_lock);
> + retval = -EINVAL;
> + goto out_free;
> + }
> + min_p = set_tid;
> + max_p = set_tid + 1;
> + set_tid = 0;
> + } else {
> + min_p = pid_min;
> + max_p = pid_max;
> + }
> /*
> * Store a null pointer so find_pid_ns does not find
> * a partially initialized PID (see below).
> */
> - nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
> - pid_max, GFP_ATOMIC);
> + nr = idr_alloc_cyclic(&tmp->idr, NULL, min_p,
> + max_p, GFP_ATOMIC);
do we really want _cyclic() which updates idr->idr_next if set_tid?
perhaps idr_alloc() makes more sense?
Oleg.
Powered by blists - more mailing lists