From: Andrew Morton <akpm@linux-foundation.org>
To: ktsanaktsidis@zendesk.com
Cc: linux-kernel@vger.kernel.org, trivial@kernel.org,
Michal Hocko <mhocko@suse.cz>, Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH] fork: report pid exhaustion correctly
Date: Mon, 3 Sep 2018 16:22:15 -0700 [thread overview]
Message-ID: <20180903162215.3069867de3ed953ae1484e06@linux-foundation.org> (raw)
In-Reply-To: <20180903111016.46461-1-ktsanaktsidis@zendesk.com>
On Mon, 3 Sep 2018 04:10:16 -0700 ktsanaktsidis@zendesk.com wrote:
> From: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
>
> Make the clone and fork syscalls return EAGAIN when the limit on the
> number of pids /proc/sys/kernel/pid_max is exceeded.
>
> Currently, when the pid_max limit is exceeded, the kernel will return
> ENOSPC from the fork and clone syscalls. This is contrary to the
> documented behaviour, which explicitly calls out the pid_max case as one
> where EAGAIN should be returned. It also leads to really confusing error
> messages in userspace programs which will complain about a lack of disk
> space when they fail to create processes/threads for this reason.
>
> This error is being returned because the alloc_pid function uses the idr
> api to find a new pid; when there are none available, idr_alloc_cyclic
> is returns -ENOSPC, and this is being propagated back into userspace.
>
> This behaviour has been broken before, and was explicitly fixed in
> commit 35f71bc0a09a ("fork: report pid reservation failure properly"),
> so I think -EAGAIN is definitely the right thing to return in this case.
> The current behaviour change dates from commit 95846ecf9dac ("pid:
> replace pid bitmap implementation with IDR AIP") and was I believe
> unintentional.
>
> This patch has no impact on the case where allocating a pid fails
> because the child reaper for the namespace is dead; that case will still
> return -ENOMEM.
Thanks. First ever kernel patch? It was a damn good one!
> Fixes: 95846ecf9dac ("pid: replace pid bitmap implementation with IDR AIP")
> Signed-off-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
I'll add cc:stable here so the fix gets backported into earlier kernels
next prev parent reply other threads:[~2018-09-03 23:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 11:10 [PATCH] fork: report pid exhaustion correctly ktsanaktsidis
2018-09-03 23:22 ` Andrew Morton [this message]
2018-09-03 23:30 ` KJ Tsanaktsidis
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=20180903162215.3069867de3ed953ae1484e06@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ktsanaktsidis@zendesk.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=oleg@redhat.com \
--cc=trivial@kernel.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;
as well as URLs for NNTP newsgroup(s).