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=1796443281; b=e3XhENVZ6E8O3eTWJ0UyfyDvAfHRRg9auKkYMcNONGJ761DP6cdZjxfBr9vXDbSvL+ox CXPY2dg7GCCHJt3xzaHepqPxaEWjkcGdP+lhH36kSUaQ2jBSAcottTTww3GQbqbRYNurO Y2sMKBWw0CLAzUlELar0X6GoB2E/fLNZvufNxzEUMCZ2hMgaSSxSuoql1Z4A4a2SDxMl5 Lhxd9eSKdBEYVrl6iHyUBF6kRir6N86SkAu5Ds5CkoGbaWKLbAO1r0vuh1rs5TCXp8qNJ hi8+2r2jQElNy/RrQFn18ZRKjnU+7MAaSPwljGS8J3YmKWb9kWz4DrzSUh1PB+hCZmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443281; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=SQzKGwR6XDuFcEaF/Rp83RlFb3AkU04BXmqOrAXKVy8=; b=MZpRF8fesZifo37NqXVKI+2OK6TElOCzQZS4lBIphOw+32Tdfiorpf02z/lUYo8540lP 6KI32ZKbVd2JzZFnF+oxKLikzGpXeEzg13BLE7kKvKQ/XEdiSx2SuCKevmrqEGdxlStbb o/VcHy/f8d6F3V145IMhQUq8913sKHv5TaWKEiE0LdyEOwJ3tayOsvfPtQJP/KVG/NbNS n0FOcefq7G3dVLpZL8liLQHrc9HGbNXJHB8TsjEMVKxE3YlQHSyQXMwTyNnaoLUt2/vXZ gQx1FAdUQ8LMMcH8sR8H6L/WS3kkn1dNHXDXM3MHv53bRriytd89hiwQMv/BbykcFWg== 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=AOJNft8h; 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 6ABBF606A338; Sat, 5 Dec 2026 04:01:21 +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 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-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 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