From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796096184; b=Os5fJ3gaOyVeQDtYCZEGjhpbMt2gRKLOqvdZVmqvLnArmuFZyN2J/h/LGnR1HxxaSW/l w4lFkAUsuyxoewF8VWh4kzIqC5ECGyPOCFhHtOFi+6BVGLtaYwFntP7JtlR3jJ9sdeuRD uG3/ozp4GlrGeF+YFHt44EsTKM9pw1vDaOXc7hiRzPwI9o6l2kcnOMhOe6wqSEvSQ2Or9 KPhSz8DkAwUYwM/gUF7eyra1fE8YygoJ1Eos/hNvMlHtKgC39/1c4AZnXdO4mzWEwn3JX 7CcTON1JstmKFJasJOuUuliTUPiFUD/KCWOCMGjoIulHsarYuIe9gYu6BiKC0KA7Icg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796096184; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=dw2/gT4ak5f0grXDZ+Ig9gpBvMsLSJZaUnOosThdD6A=; b=h5kFqfOC78Pj/SfeCSYklnsQMQsjOxtgPBsjoQ1bTSuWXwvaZV1WyKIegFvKCBeAuTkU LrDEQGJIVPqE1P5p25NLmjHmwFlnup1cURqqTlY5Pt1JPEwC4tbATX7jUVWUfVnoFA6u2 hITTDZ8JFCwklAXECFWXnP+HnEuRDtmZEkwCFxw5E/moGCemywDrHgQjBb7EuXp1J17B2 afTq6Tf2rFmVV2QoPnpQDtkDJ/LcaV6K5D/zCjRmv9cZ2dmY5aX8MV8O0gZC/n4S8psMe 5rVV8znMDGXP4JW6ZXdz4MF/JForgDIwQagRzRdLErs3rix1ZTFJWrr3wMxHlry1hpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nQChpq53; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48803606A320; Tue, 1 Dec 2026 03:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nQChpq53 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0C3B1F000C1; Tue, 1 Dec 2026 03:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796096183; bh=dw2/gT4ak5f0grXDZ+Ig9gpBvMsLSJZaUnOosThdD6A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nQChpq53/lswvGdF9ReKJhnpVvDjL/yphOgB0ohTSDo0ZqhWeAK29BA7qlQx5sqzw rg5sHho2pqbmgQ0cqcgL9nGBTVgLy5rwGVmP+Sjp8YtoaMuMGy0K77Y4xMnjF9jyGA Eea4xY4kwrzFiGpz5WPfRAlj9KE3k9PUj2A89/k+2Hwuf+kaiu7X9vlOG4dTinnZtN /eC9Um+2OT7wQ2YoWcW9uciDJKoHNLt6ZGmMzd5x59qQnPp9Nzi0g5kGugV2WtZfZr uRBWOaLegSomWWCaa7zTAK26FsLyp62qwwIJ2mjuQ1pX0a5zjktQYxMH3m5PN8TTRu qU1MTsnZn1OKg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v9 06/29] mount: Support MOVE_MOUNT_T_MNTNS in move_mount() Reply-To: sashiko-reviews@lists.linux.dev To: "Jarkko Sakkinen" Cc: bpf@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, "Aleksa Sarai" , "Alexander Mikhalitsyn" , "Alexander Viro" , "Alexei Starovoitov" , "Andrew Morton" , "Andrii Nakryiko" , "Andy Lutomirski" , "Arnd Bergmann" , "Baolin Wang" , "Ben Segall" , "Christian Brauner" , "Daniel Borkmann" , "David Hildenbrand" , "David Howells" , "David Woodhouse" , "Davidlohr Bueso" , "Dietmar Eggemann" , "Eduard Zingerman" , "Emil Tsalapatis" , "Eric Biggers" , "Georgia Garcia" , "Giuseppe Scrivano" , =?utf-8?b?R8O8bnRoZXIgTm9hY2s=?= , "Hugh Dickins" , "Ihor Solodrai" , "Ingo Molnar" , "James Morris" , "Jan Kara" , "Jason Gunthorpe" , "Jeff Layton" , "Jiri Olsa" , "John Johansen" , "Jonathan Corbet" , "Josef Bacik" , "Juri Lelli" , "Kees Cook" , "K Prateek Nayak" , "KP Singh" , "Kumar Kartikeya Dwivedi" , "Lennart Poettering" , "Liam R. Howlett" , "Manfred Spraul" , "Martin KaFai Lau" , "Matt Bobrowski" , "Mel Gorman" , "Michal Hocko" , =?utf-8?b?TWlja2HDq2wgU2FsYcO8bg==?= , "Mike Rapoport" , "Neal Gompa" , "Oleg Nesterov" , "Paul Moore" , "Pavel Tikhomirov" , "Peter Zijlstra" , "Randy Dunlap" , "Serge E. Hallyn" , "Serge Hallyn" , "Shuah Khan" , "Song Liu" , "Stephen Smalley" , "Steven Rostedt" , "Valentin Schneider" , "Vincent Guittot" , "Yonghong Song" , "Zygmunt Krynicki" In-Reply-To: <20261201031002.593830-7-jarkko@kernel.org> References: <20261201031002.593830-1-jarkko@kernel.org> <20261201031002.593830-7-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:36:20 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] fs: wrong cross-userns mount locking in attach_recursive_mnt() propagation -- commit 01b19cb52ebce04625295530b64ccf410f04c2f8 Author: Jarkko Sakkinen mount: Support MOVE_MOUNT_T_MNTNS in move_mount() This commit adds the MOVE_MOUNT_T_MNTNS flag to move_mount() to attach detached anonymous mount trees into a target mount namespace specified by an nsfs file descriptor. > diff --git a/fs/namespace.c b/fs/namespace.c > index 1bb9f90a65239..8eea00d1dbdbf 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c [ ... ] > @@ -2632,13 +2647,15 @@ enum mnt_tree_flags_t { > * Otherwise a negative error code is returned. > */ > static int attach_recursive_mnt(struct mount *source_mnt, > - const struct pinned_mountpoint *dest) > + const struct pinned_mountpoint *dest, > + struct user_namespace *src_user_ns) > { > struct mount *dest_mnt =3D dest->parent; > struct mountpoint *dest_mp =3D dest->mp; > HLIST_HEAD(tree_list); > struct mnt_namespace *ns =3D dest_mnt->mnt_ns; > struct user_namespace *user_ns =3D ns->user_ns; > + bool cross_src =3D src_user_ns && !in_userns(ns->user_ns, src_user_ns); > struct pinned_mountpoint root =3D {}; > struct mountpoint *shorter =3D NULL; > struct mount *child, *p; > @@ -2688,7 +2705,8 @@ static int attach_recursive_mnt(struct mount *sourc= e_mnt, > err =3D invent_group_ids(source_mnt, true); > if (err) > goto out; > - err =3D propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list); > + err =3D propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list, > + cross_src); > } > lock_mount_hash(); > if (err) > @@ -2725,11 +2743,22 @@ static int attach_recursive_mnt(struct mount *sou= rce_mnt, > hlist_add_head(&source_mnt->mnt_hash, &tree_list); > =20 > hlist_for_each_entry_safe(child, n, &tree_list, mnt_hash) { > + struct user_namespace *child_user_ns =3D > + child->mnt_parent->mnt_ns->user_ns; > + bool cross_child_src =3D cross_src && > + !in_userns(child_user_ns, src_user_ns); > 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 !=3D user_ns) > + /* > + * Notice when we are propagating or attaching a foreign > + * source tree across user namespaces. > + */ > + if (child_user_ns !=3D user_ns || cross_child_src) { > lock_mnt_tree(child); > + if (cross_child_src && list_empty(&child->mnt_expire)) > + child->mnt.mnt_flags |=3D MNT_LOCKED; > + } > q =3D __lookup_mnt(&child->mnt_parent->mnt, > child->mnt_mountpoint); > commit_tree(child); [Severity: High] Does gating cross_child_src and propagate_mnt()'s lock_source on cross_src mishandle shared mount propagation across different user namespaces? cross_src only compares src_user_ns against the primary destination ns->user_ns. When in_userns(ns->user_ns, src_user_ns) is true (so cross_src is false), but dest_mnt propagates to a slave or peer mount in a less-privileged user namespace where !in_userns(child_user_ns, src_user_ns) holds, propagate_mnt() runs without CL_LOCK_SOURCE and copy_tree() silently drops unlocked unbindable or nsfs submounts instead of returning -EPERM, exposing the underlying covered directories. In the tree_list loop, cross_child_src also stays false, leaving child without MNT_LOCKED even when child_user_ns =3D=3D user_ns does not hold or when lock_mnt_tree() only locks submounts below child. Conversely, when cross_src is true, propagate_mnt() passes CL_LOCK_SOURCE to copy_tree() for every secondary mount n regardless of n->mnt_ns->user_ns (and chains copy =3D this with MNT_LOCKED already set on submounts), rejecting unbindable/nsfs submounts with -EPERM and locking submounts even in peer namespaces that are privileged over src_user_ns. Checking !in_userns(n->mnt_ns->user_ns, src_user_ns) per secondary target in propagate_mnt() (without mutating the source tree used for subsequent peers) and dropping cross_src from the cross_child_src condition would evaluate each target namespace against src_user_ns directly. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201031002.5938= 30-1-jarkko@kernel.org?part=3D6