Re: [PATCH] ns: skip namespace_init LSM hook for internal namespaces

From: Christian Brauner

Date: Fri Nov 20 2026 - 07:33:08 EST


On Sat, Nov 14, 2026 at 10:13:23PM +0800, Zhiqi Zhang wrote:
> Skip LSM initialization for kernel-internal namespaces.
> __ns_common_init() gains an lsm parameter, and a new
> ns_common_init_inum_internal() passes false. It is used by
> mount_subtree() only; user-visible namespace allocations (clone,
> unshare, setns, open_tree, fsmount) keep calling the hook.

Thanks for the report! I wrote a different fix that skips both
namespace_init and namespace_free for such namespaces so the two hooks
stay paired:

https://patch.msgid.link/20261120-work-ns-mount_subtree-v1-0-06337377f94a@xxxxxxxxxx