Re: [PATCH v2] nstree: check listing permission before taking a namespace reference

From: Christian Brauner

Date: Wed Sep 09 2026 - 04:14:42 EST


On Mon, 07 Sep 2026 16:22:17 +0200, Norbert Szetei wrote:
> legitimize_ns() takes a reference on the candidate namespace before
> may_list_ns() has decided whether the caller may see it. The
> __free(ns_put) cleanup on the denied path can drop the last reference to a
> mount namespace while we still hold the rcu read lock, and put_mnt_ns()
> may sleep there. This is the same problem commit 2ec2aff3c8e2 ("ns: make
> sure reference are dropped outside of rcu lock") fixed for the put_user()
> path. Neither ns_requested() nor may_list_ns() needs a reference, both
> only look at the namespace type and at the caller's own namespaces, so do
> the checks first and take the reference last.
>
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes 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: vfs.fixes

[1/1] nstree: check listing permission before taking a namespace reference
https://git.kernel.org/vfs/vfs/c/ecfee3a7c9ea