From: "Michal Koutný" <mkoutny@suse.com>
To: Shaojie Sun <sunshaojie@kylinos.cn>
Cc: Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Christian Brauner <christian@brauner.io>,
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Subject: Re: [PATCH] cgroup: namespace: replace BUG_ON() in copy_cgroup_ns() with WARN_ON_ONCE()
Date: Wed, 2 Sep 2026 20:56:42 +0200 [thread overview]
Message-ID: <aphwXq5bEQwKhqx2@localhost.localdomain> (raw)
In-Reply-To: <20260902101856.225493-1-sunshaojie@kylinos.cn>
[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]
Hi Shaojie.
On Wed, Sep 02, 2026 at 06:18:56PM +0800, Shaojie Sun <sunshaojie@kylinos.cn> wrote:
> copy_cgroup_ns() uses BUG_ON() to guard against a NULL old_ns. The
> condition cannot currently be triggered by any caller, and the sole
> caller, create_new_namespaces(), already checks the return value with
> IS_ERR() and unwinds correctly.
>
> Replace the BUG_ON() with WARN_ON_ONCE() and return -EINVAL instead,
> consistent with the policy of not killing the whole machine for a
> recoverable programming error.
Do you plan to tackle other namespaces too? (Adding their guys to Cc:)
It'd be good to have some consistency across them if this is going to be
touched. (I see that some simply don't care whereas others have the same
BUG_ON(). I might personally prefer the former)
Regards,
Michal
>
> Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
> ---
> kernel/cgroup/namespace.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/namespace.c b/kernel/cgroup/namespace.c
> index ea4ee13936be..13930955c254 100644
> --- a/kernel/cgroup/namespace.c
> +++ b/kernel/cgroup/namespace.c
> @@ -53,7 +53,8 @@ struct cgroup_namespace *copy_cgroup_ns(u64 flags,
> struct ucounts *ucounts;
> struct css_set *cset;
>
> - BUG_ON(!old_ns);
> + if (WARN_ON_ONCE(!old_ns))
> + return ERR_PTR(-EINVAL);
>
> if (!(flags & CLONE_NEWCGROUP)) {
> get_cgroup_ns(old_ns);
> --
> 2.50.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
next prev parent reply other threads:[~2026-09-02 18:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 10:18 [PATCH] cgroup: namespace: replace BUG_ON() in copy_cgroup_ns() with WARN_ON_ONCE() Shaojie Sun
2026-09-02 18:56 ` Michal Koutný [this message]
2026-09-03 6:48 ` [PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers Shaojie Sun
2026-09-03 6:48 ` [PATCH v2 1/3] cgroup: namespace: drop BUG_ON() in copy_cgroup_ns() Shaojie Sun
2026-09-03 9:28 ` Tao Cui
2026-09-03 16:47 ` Tejun Heo
2026-09-03 6:48 ` [PATCH v2 2/3] uts: drop BUG_ON() in copy_utsname() Shaojie Sun
2026-09-03 8:40 ` Bradley Morgan
2026-09-03 6:48 ` [PATCH v2 3/3] fs: namespace: drop BUG_ON() in copy_mnt_ns() Shaojie Sun
2026-09-03 9:29 ` Tao Cui
2026-09-03 10:43 ` Jan Kara
2026-09-03 8:02 ` [PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers Shaojie Sun
2026-09-04 10:48 ` (subset) " Christian Brauner
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=aphwXq5bEQwKhqx2@localhost.localdomain \
--to=mkoutny@suse.com \
--cc=cgroups@vger.kernel.org \
--cc=christian@brauner.io \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ptikhomirov@virtuozzo.com \
--cc=sunshaojie@kylinos.cn \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.