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 EC163606A33D for ; Sat, 5 Dec 2026 04:01:25 +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=AOJNft8h Received: by kanga.kvack.org (Postfix) id 86E716B05B8; Fri, 4 Dec 2026 23:01:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 845F36B05B9; Fri, 4 Dec 2026 23:01:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75C4D6B05BA; Fri, 4 Dec 2026 23:01:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3F5BD6B05B8 for ; Fri, 4 Dec 2026 23:01:24 -0500 (EST) Received: from smtpin19.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9A1BB1C3C87 for ; Sat, 5 Dec 2026 04:01:23 +0000 (UTC) X-FDA: 85508579646.19.929AFD5 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf18.hostedemail.com (Postfix) with ESMTP id 0BDFD1C0004 for ; Sat, 5 Dec 2026 04:01:21 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=AOJNft8h; spf=pass (imf18.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796443282; b=FPT+IZZPIE0tTN369jTuNIKmDt3m0/8/xPzgkp8H10TQOyRxD6mT9+DAMei1fVd58edfBG vi154S8CpqacSGBoSjZTQ5zGeCswkXlRyb9ycwm9QdaOHgUnWSOQN0X1cKcJwX5JucOdKH CjvdDFs5DYGl8JL4icSPETcpHNhBRBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796443282; 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=SQzKGwR6XDuFcEaF/Rp83RlFb3AkU04BXmqOrAXKVy8=; b=XZOJmksDk0gudfNqzWi1zKeRdH7NJB7uoG2+FJC4gchaisFHWeCK2mrSabvpQ67BsY1F+1 YJfXN7GTX4mG3g7fhswABe/cIFRRNBIiXFch8vxLbx8kbix3ZR/XDOMOT9T9ger782wjrs OUiPEsGKWS+FeV9QwtHq6gByC95gU2w= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=AOJNft8h; spf=pass (imf18.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 319A4601FE; Sat, 5 Dec 2026 04:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02FCB1F00A14; Sat, 5 Dec 2026 04:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443281; bh=SQzKGwR6XDuFcEaF/Rp83RlFb3AkU04BXmqOrAXKVy8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=AOJNft8hQIqxvPavD3SKEKdIBYIeGe7qT7xmZpvr7IlvKQu+Zvj/v3NgIdoVPjZ5r hR4pY2xE82AliOHMoapU5xrI1cAvfGt8aMUFZHB4bPcCVkbAfsH9PZUH449I/fstQC /TlqvnOTF3y7Xpx4igiZ7fWG1DjOTrg404SfU9VlLH2Ug9CQGCeXhg2pnqtd+CvcEi LIBRoLTbsCTnIXrfB+6ppZlNa40WYKCz4AUUQ4VgjGfxEaSslgv6UEsQRZga5jw4qU HKrF8mEqZgmTHa4C4vW+u4I+BzcXvFViQ4aI4ra6wJDDG/DHcCuylTocN3mYqAgXwT jhmFrDbB/c2xw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v10 07/28] mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS 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: <20261205032633.1702772-8-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> <20261205032633.1702772-8-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:01:17 +0000 X-Rspam-User: X-Rspamd-Queue-Id: 0BDFD1C0004 X-Rspamd-Server: rspam03 X-Stat-Signature: fmt6to96khbxrgkwx7qxay53gpemuegf X-Spam-Status: No, score=-11.1 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: 1796443281-648937 X-HE-Meta: U2FsdGVkX18n0PgYslJFguKTRbSBGZcl/w1z1n/j9JMpXCGYzCkc0Ua46A+k+SmR+5WVxuXTMd/N1NoQ/vBkmgIKPcVJgxBFmC29KitVt3NjYUC+AKPMzuk1ZdGr8TXNP2/RkRkjZWpaq5C7LiG+qbaqMQAic+p5aCutlcsWPJQu2HpIbvt9/5nm8dymGV+c1hRvHQfaFgBePEfSOgrJoyggjgbqnutTvQ6kIFSanbujJCvymVhnVYTljwfX5ALScd36dV0/93cEypoeFvt2f5i6sKQJnXeOkDi6gQQjRY7FtFTjQlw3N+ng637di23TVz8UJxrkDJrnvhzh8M7UOyMUF6c4BR+3B817clToUtefOp2d+TGP10d9R4if1J/Z4WFcoXRgbfXghDSjwSCalBVW/+OGJr1yPErfuLP0u/GKQdIsfwIWJCSHi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Nppd94rV3Eaxn0wNK7kEDqe0FAAjSdvmtTbBQzoi8IdpgIEG8KZwvcxe3TAk427jQ5ZphBzB+kdLq+SuWKu6D+d8iUfsffXSAW07uqK00GgMj/tRwcAx8NAIroIYq+zcS2cFxEqSXtujqNj0hU0gPVjns4ppsIyuGFv6ZbmppBIlT0Ygfvs/2bjkoTt0Y+OO0/Pff78SBLoqo7wmMR9plaaFxkvrh33+lNm9j+lMno1n0RfkQO1OJQh5lwf5Nk+hWhahNPPS0UqYVhd06XXdk9kmYoYK39Ve+0Y4NiQDTchHaOGXc92ZICABQpIr7U0aMpGpBa6m4zK2F3DJIL6KmWRq96jjHPm7T5VlkNHf5jmpPWVNZEuYYgZDKFFW1eQy3nvf6w6dV9ufafAEmTFbMhmH7K4ERWqUu6+F8Y68DHg99zCv6F0jRzQg== 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 3 potential issues to consider: - [Medium] fs/namespace: late d_is_symlink() check after cloning in do_move_mount() - [Medium] fs/namespace: speculative O(N) clone for shared dest in do_move_mount() - [Low] fs/namespace: undocumented rejection of self mntns in MOVE_MOUNT_CLONE -- commit 173582b09561e3cc9ce6e9cfdc929c8276e1a162 Author: Jarkko Sakkinen mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS This commit adds the MOVE_MOUNT_CLONE flag for use with MOVE_MOUNT_T_MNTNS so move_mount() can recursively loopback-clone a path from the caller's mount namespace directly into a target mount namespace file descriptor. > diff --git a/fs/namespace.c b/fs/namespace.c > index d73a215c9ae55..ced125eff59b9 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c [ ... ] > @@ -3846,6 +3844,38 @@ static int do_move_mount(const struct path *old_pa= th, > if (m =3D=3D target_mnt_ns->root) > return beneath ? -EINVAL : -EBUSY; > } > + if (flags & MNT_TREE_CLONE) { > + unsigned int copy_flags; > + > + if (!check_mnt(old) || old->mnt_ns =3D=3D target_mnt_ns || > + (old->mnt.mnt_sb->s_flags & SB_NOUSER)) > + return -EINVAL; [Severity: Low] Should MOVE_MOUNT_CLONE reject targeting the caller's own mount namespace? Because check_mnt(old) requires old->mnt_ns =3D=3D current->nsproxy->mnt_ns, the old->mnt_ns =3D=3D target_mnt_ns check returns -EINVAL whenever to_dfd refers to /proc/self/ns/mnt. Non-clone MOVE_MOUNT_T_MNTNS and do_loopback() both allow the caller's own namespace, and neither the commit message nor DOC: MOVE_MOUNT_T_MNTNS documents this restriction. > + src_user_ns =3D old->mnt_ns->user_ns; > + if (!in_userns(target_mnt_ns->user_ns, src_user_ns)) > + copy_flags =3D CL_SLAVE | CL_COPY_UNBINDABLE | > + CL_LOCK_SOURCE; > + else > + copy_flags =3D CL_COPY_MNT_NS_FILE; > + cloned =3D __do_loopback(old_path, true, copy_flags); > + if (IS_ERR(cloned)) > + return PTR_ERR(cloned); > + old =3D cloned; > + if (d_is_symlink(old->mnt.mnt_root)) { > + err =3D -EINVAL; > + goto out_cloned; > + } [Severity: Medium] Can the d_is_symlink() check move before LOCK_MOUNT_MAYBE_BENEATH(), or is rejecting symlinks needed here at all? clone_mnt() sets cloned->mnt.mnt_root to old_path->dentry, so this is already known before locking. With a symlink source and non-directory target, checking it here takes exclusive namespace_sem, clones the tree, and tears it down via umount_tree(cloned, UMOUNT_SYNC). Adding the clone to the unmounted list then forces namespace_unlock() to run synchronize_rcu_expedited(), stalling concurrent mount operations and sending cross-CPU IPIs before returning -EINVAL. Rejecting symlinks is also undocumented and diverges from open_tree(OPEN_TREE_CLONE | AT_SYMLINK_NOFOLLOW) with move_mount(), which allows bind-mounting a symlink onto a non-directory target. [ ... ] > /* > * Don't move a mount tree containing unbindable mounts to a destination > * mount which is shared. > */ > - if (IS_MNT_SHARED(mp.parent) && tree_contains_unbindable(old)) > - return -EINVAL; > + if (IS_MNT_SHARED(mp.parent) && tree_contains_unbindable(old)) { > + err =3D -EINVAL; > + goto out_cloned; > + } [Severity: Medium] Could this check for unbindable source mounts happen before __do_loopback() when IS_MNT_SHARED(mp.parent) is true? When crossing a user namespace boundary onto an MS_SHARED destination, __do_loopback() passes CL_COPY_UNBINDABLE and clones the entire O(N) source subtree under exclusive namespace_sem, acquiring mount_lock per mount. If the source tree contains any unbindable submount, this check then rejects the whole clone, unmounts all N copies under lock_mount_hash(), and triggers synchronize_rcu_expedited() in namespace_unlock(), stalling concurrent mount, statmount, and listmount calls. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205032633.1702= 772-1-jarkko@kernel.org?part=3D7