From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68C26606A325 for ; Tue, 1 Dec 2026 03:36:28 +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 kanga.kvack.org (Postfix) id 7C5876B05D1; Mon, 30 Nov 2026 22:36:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 776E66B05D2; Mon, 30 Nov 2026 22:36:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 665166B05D3; Mon, 30 Nov 2026 22:36:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 271B76B05D1 for ; Mon, 30 Nov 2026 22:36:27 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7033080269 for ; Tue, 1 Dec 2026 03:36:26 +0000 (UTC) X-FDA: 85494001572.05.223FD5A Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf11.hostedemail.com (Postfix) with ESMTP id C336040007 for ; Tue, 1 Dec 2026 03:36:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=nQChpq53; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796096184; b=UdSwBYee79tzahl/ViuADxbgCf+ATwdFoc9eWe4/PZbAIYBlah+H7j5Eevw5NnR/RScNFO Ty/M3re5f2DKaJXM6z+svp1UCw96Iy6sGUX1MLu5V/v9KxP7dQ0G8U19CtUYRCIR3MNLPl NkkQhWZ8z9L0i2k7mX/PGzW7ZYHPSE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796096184; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dw2/gT4ak5f0grXDZ+Ig9gpBvMsLSJZaUnOosThdD6A=; b=OG/vT5gfHLDJhEmNHki2j89+oBorHHcN4sJgovfC4eIlXGVg+jbL74ELtAlOx2ohI6Z7WA wLSKTOAyyAH+MYLZoUvMxzhSiW26omEH6obiP74dN2ynEwr2sfY0uYqTT0Qm7/0ejc2hb8 ToMJELm+UUbkOs1Ww3bINiUDyXz1Cs0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=nQChpq53; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 021C344D40; Tue, 1 Dec 2026 03:36:24 +0000 (UTC) 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-Stat-Signature: g74zjwm7xnrhcsj9teuxd1ud39wyq1rs X-Rspam-User: X-Rspamd-Queue-Id: C336040007 X-Rspamd-Server: rspam12 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796096184-458281 X-HE-Meta: U2FsdGVkX1+apGQU62yDCrGSQnw4thIg3PK3BF4VytLuaOYHZpBm0OLgVUPZCbC0DlymVrY6M+qVk7N7F67GsKi8JJu6M2Mpiw9XaXgr9vjFrgMy6fbn+h5C9J8f4hccxtFYv55w5+kYvUt5MgLMFqLMaBilECtZM6bsTWfawQTAIoyfnad58+lYZNRvF0RtnaEfeowsbdiEklZgCpKYOFhESLWuqqzXmdIPXHLstNDFvcehBpRR+H39Q+VfKp1NF6iHlBbMWNRTr+CG9Hwwv+E/g5cLzL7nUfTdxHAElBkH16sSHO+EDNMM0QhVlgUDfq73n8PBmehOufanzvEba7xurl2Fp0bjC8274rZ0Z4BaGsXECDZXF3aZnbAjWuhytBd4OKa+owvHtJwZDDDNH9JPqFQ1LA4IODAY55ANpcXUIHcW+/Goeq9kkNa1ANLoWF49Hj/54PfM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COAZMpnh0qnf5bIGI3ZfKMYSwMn1AGpnlaa5DKPwQJ/gcLR74pKl3kuiEyIvtLkce5FL0ffyE+zMDvcKkduRDqwhPEWXyRxtPaxe0bpjh9DFb7Qpv7jJ8EPqJLTzaGYsOt5PRqbasckzMTLnxGgQxGWeB/TEKdnLEX1yZ6r/f05sUaR53rd42+5mw6nS/lBhnFlMp/9HL37QHm4LcugfKnWqgxQcU0TSbniRHJTEWmDgelXmRk4ZhyLXBvrNvKM8Pn2QSiBrYd0Ksuh1Htli2mTagqH9rtVE+z79idjSv/zxd8I8Y1tT7nuhUiZfvrfEL0Bb0JnGNmasPBg2amh8OaDtxQFaJIz7oygp4L9N8bvWLEOQ2im/5TObFf70d0/FUhIQoIvZv3S7AgiB274g== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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