Re: [RFC PATCH v6 06/26] mount: Support MOVE_MOUNT_T_MNTNS in move_mount()

From: bot+bpf-ci

Date: Sat Nov 21 2026 - 21:14:19 EST


> mount: Support MOVE_MOUNT_T_MNTNS in move_mount()

TL;DR: Nits only in attach_recursive_mnt(): the repeated cross-userns
condition could be computed once into a local, and the comment doesn't cover
the new case.

> diff --git a/fs/namespace.c b/fs/namespace.c
> --- a/fs/namespace.c
> +++ b/fs/namespace.c

[ ... ]

> @@ -2728,8 +2741,17 @@ static int attach_recursive_mnt(struct mount *source_mnt,
> struct mount *q;
> hlist_del_init(&child->mnt_hash);
> /* Notice when we are propagating across user namespaces */
> - if (child->mnt_parent->mnt_ns->user_ns != user_ns)
> + if (child->mnt_parent->mnt_ns->user_ns != user_ns ||
> + (cross_src &&
> + !in_userns(child->mnt_parent->mnt_ns->user_ns,
> + src_user_ns))) {
> lock_mnt_tree(child);
> + if (cross_src &&
> + !in_userns(child->mnt_parent->mnt_ns->user_ns,
> + src_user_ns) &&
> + list_empty(&child->mnt_expire))
> + child->mnt.mnt_flags |= MNT_LOCKED;
> + }

This isn't a bug, but could the repeated test

cross_src && !in_userns(child->mnt_parent->mnt_ns->user_ns, src_user_ns)

be computed once into a local here? It is evaluated in both the outer
condition and the inner one, and child->mnt_parent->mnt_ns->user_ns is
spelled out three times.

Also, the comment above ("Notice when we are propagating across user
namespaces") doesn't describe the new arm, which fires for the mount the
caller placed itself (child == source_mnt) when the source tree's owner is
outside the destination's user namespace, with no propagation involved.
Could the comment be updated to cover that case?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44972669664