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=1795912091; b=Uuk2+g/9kOY4AbrPn6p/3rnp/0QrNToEwZJcSbM89SAjD/JExp+v0rPD4H78HUD4XIFA DS77yd5KbdcylA76E4KAldl8LeMFeQd0ELyUfp0IiiSQHnR1CZmT7chf3o13koeEb2wrn /E24ezKhQHdQarKfF/u5Sri3g9x1CSiIfRwujOB5G7fBKFp6e5Sjuvi1i52gY1F9rng5N 6GLvKvHzgkrNTDMIVimEDt5yZ6JFec657PaXLLB9k924h21CnBknODEf0AIS065JFGL9C y7GhZeIUyEsASBI60Fwarevfnw0oNDKRyMPHYHsmaYeEW09ZDFKB73qcm1bSnH6XEvA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795912091; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=68ZrrXp9LTUlXDDezLUtddhU27+VEeyGo8xIG15K2Gk=; b=cdQkEeF7XBEM+sWJi036TLqEZI25aZXedJsYqMPC2l3PzExw+2qyGzLZ5UfzS9hj7tUZ AOIH/IpcrlJPn8y8VdBpAY/4tw53QyYoFjqZ+K3gCkqIUlZrh19wWf9xL7ZoRtd74fgNr 226krfaRu4NWvRMm3KhZ1YRZHglonaBqfPSJlsSyZBCbnp00pWCSqdwwldR+3fzIEua8L CsNAu4mBsBFW5hvowaYIxhSgkHTR4QgEaBE/Cm09RI8sqHoBsEvcP2ULaTespagdPNm1A 4hvhVSgMRIk93YxfBs3cMZW6kf/BUX+kihN+/WuNxr2zFkkfg7fXVAJLdL3UFdxQA8g== 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=HEUXOmMF; 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 BF4D0606A31C; Sun, 29 Nov 2026 00:28:11 +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=HEUXOmMF Received: by smtp.kernel.org (Postfix) with ESMTPSA id E11111F000C1; Sun, 29 Nov 2026 00:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795912091; bh=68ZrrXp9LTUlXDDezLUtddhU27+VEeyGo8xIG15K2Gk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HEUXOmMFSVPQEm7qyDxVuZXdhUMP+HO5IiMJ0CclbEPQvtDk8ZotzV3qE+C//ej+W bzJpKMCQfJ4iE8ikY+1ZgDe9kcSwG/e8Phw5OpYvj4h6uCFpnOyIjanFaNgDZgzrIU +vH7sh8ChRHJpgmJ9GVV5Pm3Wrur7pacRFpcz0lhsv4Rm0IpnOdBjOWVevwvHvYfc9 +eQS1dkhKAT0HPOGQKp7oFNqk562tFPBduHBrvrYs4lVfPwpQKgq1/34B/adKzDh5I rEzxwlaJSdOjyI0WToCOsK2+lu/xos5hv6d+ItG2891XA4Yxdc0iHLplVH0T7aUyk2 B3w8kjukhc6+Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v8 08/29] 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" , "Andy Lutomirski" , "Arnd Bergmann" , "Christian Brauner" , "David Howells" , "Eric Biggers" , "Georgia Garcia" , "Giuseppe Scrivano" , "Hugh Dickins" , "James Morris" , "Jan Kara" , "Jeff Layton" , "John Johansen" , "Jonathan Corbet" , "Josef Bacik" , "Kees Cook" , "KP Singh" , "Lennart Poettering" , "Matt Bobrowski" , =?utf-8?b?TWlja2HDq2wgU2FsYcO8bg==?= , "Neal Gompa" , "Oleg Nesterov" , "Paul Moore" , "Pavel Tikhomirov" , "Serge Hallyn" , "Shuah Khan" , "Stephen Smalley" , "Zygmunt Krynicki" In-Reply-To: <20261128235808.2369970-9-jarkko@kernel.org> References: <20261128235808.2369970-1-jarkko@kernel.org> <20261128235808.2369970-9-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 00:28:09 +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] mount: missing CL_LOCK_SOURCE in do_move_mount() cross-userns clone -- commit 0d1d8da112faced6c7bc49b0fc725fadd1aaab58 Author: Jarkko Sakkinen mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS This commit adds MOVE_MOUNT_CLONE 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 fadc4c3b1fb2a..e60c589ae0152 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c [ ... ] > @@ -3847,6 +3845,36 @@ 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; > + src_user_ns =3D old->mnt_ns->user_ns; > + copy_flags =3D (target_mnt_ns->user_ns !=3D src_user_ns) ? > + (CL_SLAVE | CL_COPY_UNBINDABLE) : > + CL_COPY_MNT_NS_FILE; > + cloned =3D __do_loopback(old_path, true, copy_flags); [Severity: High] Should copy_flags include CL_LOCK_SOURCE and test !in_userns(target_mnt_ns->user_ns, src_user_ns) when cloning across user namespaces? Native non-expiring submounts in old->mnt_ns do not have MNT_LOCKED set before attach_recursive_mnt() runs: fs/namespace.c:copy_tree() { ... bool src_locked =3D (src_mnt->mnt.mnt_flags & MNT_LOCKED) || ((flag & CL_LOCK_SOURCE) && list_empty(&src_mnt->mnt_expire)); ... if (!(flag & CL_COPY_MNT_NS_FILE) && is_mnt_ns_file(src_mnt->mnt.mnt_root)) { if (src_locked) { /* Both a mount namespace file and locked. */ dst_mnt =3D ERR_PTR(-EPERM); goto out; } src_mnt =3D skip_mnt_tree(src_mnt); continue; } ... } Without CL_LOCK_SOURCE, copy_tree() sees src_locked as false and skips any nsfs submount and its overmounts via skip_mnt_tree() instead of returning -EPERM, exposing underlying files or directories covered in the source mount namespace. In addition, when target_mnt_ns->user_ns is an ancestor of src_user_ns, checking target_mnt_ns->user_ns !=3D src_user_ns passes CL_COPY_UNBINDABLE even though attach_recursive_mnt() computes cross_src =3D !in_userns(ns->user_ns, src_user_ns) as false, leaving copied unbindable submounts unlocked and causing attachment onto a shared destination mount to fail with -EINVAL in tree_contains_unbindable(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128235808.2369= 970-1-jarkko@kernel.org?part=3D8