[PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers

Shaojie Sun posted 3 patches 3 weeks, 2 days ago
fs/namespace.c            | 2 --
kernel/cgroup/namespace.c | 2 --
kernel/utsname.c          | 1 -
3 files changed, 5 deletions(-)
[PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers
Posted by Shaojie Sun 3 weeks, 2 days ago
v2:
- Reworked into a 3-patch series that simply drops the BUG_ON()s
  instead of replacing them with WARN_ON_ONCE() + error return,
  following the discussion with Tejun. Now also covers copy_utsname()
  and copy_mnt_ns() so that all copy_*_ns() helpers behave
  consistently.

The copy_*_ns() helpers are inconsistent in how they handle a NULL
namespace pointer. copy_mnt_ns(), copy_utsname() and copy_cgroup_ns()
have a BUG_ON() on the pointer, while copy_time_ns(), copy_pid_ns(),
copy_ipcs() and copy_net_ns() don't check it at all.

The sole caller, create_new_namespaces(), always passes the
corresponding namespace pointer from the task's nsproxy, so the checks
can never trigger and the helpers dereference the pointer right away
anyway.

Drop the BUG_ON()s so that all copy_*_ns() helpers behave consistently.
The maintainers of the respective subsystems are on Cc.

Shaojie Sun (3):
  cgroup: namespace: drop BUG_ON() in copy_cgroup_ns()
  uts: drop BUG_ON() in copy_utsname()
  fs: namespace: drop BUG_ON() in copy_mnt_ns()

 fs/namespace.c            | 2 --
 kernel/cgroup/namespace.c | 2 --
 kernel/utsname.c          | 1 -
 3 files changed, 5 deletions(-)

-- 
2.50.1
Re: [PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers
Posted by Shaojie Sun 3 weeks, 2 days ago
Apologies, the cover letter of this series says

    "... following the discussion with Tejun."

It should read "... following the discussion with Michal Koutný".
The patches themselves are unaffected.

Thanks,
Shaojie
Re: (subset) [PATCH v2 0/3] drop BUG_ON() NULL checks in namespace copy helpers
Posted by Christian Brauner 3 weeks ago
On Thu, 03 Sep 2026 14:48:25 +0800, Shaojie Sun wrote:
> drop BUG_ON() NULL checks in namespace copy helpers
> 
> v2:
> - Reworked into a 3-patch series that simply drops the BUG_ON()s
>   instead of replacing them with WARN_ON_ONCE() + error return,
>   following the discussion with Tejun. Now also covers copy_utsname()
>   and copy_mnt_ns() so that all copy_*_ns() helpers behave
>   consistently.
> 
> [...]

Applied to the namespace-7.4.misc branch of the vfs/vfs.git tree.
Patches in the namespace-7.4.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: master

[2/3] uts: drop BUG_ON() in copy_utsname()
      https://git.kernel.org/vfs/vfs/c/d54cc3a5272c
[3/3] fs: namespace: drop BUG_ON() in copy_mnt_ns()
      https://git.kernel.org/vfs/vfs/c/4141e148e629