From: ebiederm@xmission.com (Eric W. Biederman)
To: Matthew Wilcox <willy@infradead.org>
Cc: Gargi Sharma <gs051095@gmail.com>, Rik van Riel <riel@redhat.com>,
Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] Fix failure path in alloc_pid()
Date: Wed, 19 Dec 2018 03:28:41 -0600 [thread overview]
Message-ID: <87woo5c1bq.fsf@xmission.com> (raw)
In-Reply-To: <20181218215321.GW10600@bombadil.infradead.org> (Matthew Wilcox's message of "Tue, 18 Dec 2018 13:53:21 -0800")
Matthew Wilcox <willy@infradead.org> writes:
> The failure path removes the allocated PIDs from the wrong namespace.
> I believe this is correct, but have not tested it. Spotted by inspection,
> do we have a test suite for PID namespaces? Some error injection,
> perhaps?
>
> Fixes: 95846ecf9dac ("pid: replace pid bitmap implementation with IDR API")
>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
> diff --git a/kernel/pid.c b/kernel/pid.c
> index b2f6c506035da..75264e0d1e71d 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -233,8 +233,11 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>
> out_free:
> spin_lock_irq(&pidmap_lock);
> - while (++i <= ns->level)
> - idr_remove(&ns->idr, (pid->numbers + i)->nr);
> + upid = pid->numbers + i;
> + while (++i <= ns->level) {
> + upid++;
> + idr_remove(&upid->ns->idr, upid->nr);
> + }
>
> /* On failure to allocate the first pid, reset the state */
> if (ns->pid_allocated == PIDNS_ADDING)
next prev parent reply other threads:[~2018-12-19 9:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 21:53 [RFC] Fix failure path in alloc_pid() Matthew Wilcox
2018-12-19 9:28 ` Eric W. Biederman [this message]
2018-12-20 16:20 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87woo5c1bq.fsf@xmission.com \
--to=ebiederm@xmission.com \
--cc=gs051095@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=riel@redhat.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox