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=1796442703; b=svDyIqY17RFq8fN4EavCGLQ9AQygcdY7fAoTSA4IZOPmUjx+UoT6DbM81DUAzuY/HTdH 8WmwcB6aMAjfLA4TV/C14Cw5Z89SlvPHkdQ/V7BYDOHxBCzXzZS+JycBiO3YpFyTc0IbY IBkz7DKypb4OxCnacP5Dg0GVcBbKg7hVKTIsH+HCANpo1/u9SWS1yIoghnwQCnF6MAsob 788Ip0OV7KS8Zh3uaiYdBjzopr2v1HPWxMM9GH7tSoi0h34YduSThh5PmHAnAqGisb8u+ Cy9AsJk8hXn0Lm1R21q3G32nTfiGDOpFffauLmFbr0rPnvuT5XA1x8zizSkzkhy45VQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796442703; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=v+catJ+o6PB0WBkdXWPw+EDyFP57wmMY1zhVMpocFog=; b=rLEdYUjiQ5IhbUomGnxgkOc8pGD/FmeoH7M1+g9LGmw/bao5zQy/7pXevcPvTxAxIrJq scsLgoTGoVTkvPmEJIVYMs00RIovdk90JXkg7o3bRFyFdb4fRtvjPeVCdkLROlQFhSxsG 83EqTv3ki3wxiBBBKxmjqwftyKHiYeefFy3/yKpa5f0XcycZAYcAEnZN50cZZk739wJRx /CjmACAZRq7gBTLqkeVwLEDT22dsG5GAyY58iY7pNxBNTWtGn2ASr8CILQnQ7Xj7DVKJn ho3fhyWRwLTbvmYj9Ygeu6nj+6GZn5SMnojwQYO3T/L2iFnX4PCh4mWCf/htFjYBZxQ== 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=RL+jCVxc; 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 812CF606A322; Sat, 5 Dec 2026 03:51:43 +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=RL+jCVxc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85A471F0092B; Sat, 5 Dec 2026 03:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796442703; bh=v+catJ+o6PB0WBkdXWPw+EDyFP57wmMY1zhVMpocFog=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RL+jCVxcY2whdm8505WbRDwBE1gHrs01jFhTQ6rSvIzARlc01rmHeUHOR2cesdayh Zo6TX9tQlaBhHagZgYetLrVYl7l7VHxr0sRr09cDsuEEXrQyIQpBr5iag4aLQWJgsv i+z3fXni/S4/xcYJNkjSLQ2i64Vtfmpvy4TPoYSO//9Ep9aNHUcL5+Q0ByH8TxQAmX JVFan88ysWaLO8IGo03yyw0G6+QU/j9fTLOX5k8fWKpO4W4zxCb2tbudhbcwbNh3Da KhnltCISwuYJLVmnIApKef/vYZMR8J/VhobVbYh+JBRZ/UPP6qPtw7bCBz9qYsMyS3 9JL5zH1Oux2iQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v10 08/28] apparmor: Mediate MOVE_MOUNT_CLONE as recursive bind 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-9-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> <20261205032633.1702772-9-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 03:51:40 +0000 X-Mailing-List: linux-security-module@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] apparmor: PATH_TARGET_MNTNS bypasses disconnected and chroot containment -- commit 422115d303e61b6a1be5047606a4ec753ad68040 Author: Jarkko Sakkinen apparmor: Mediate MOVE_MOUNT_CLONE as recursive bind This commit passes move_mount() flags into aa_move_mount(), mediates MOVE_MOUNT_CLONE as MS_BIND | MS_REC while rejecting foreign or detached sources, and adds PATH_TARGET_MNTNS to resolve cross-namespace MOVE_MOUNT_T_MNTNS destination paths against the target mount namespace roo= t. > diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c > index 4ed7b9136bebf..2dfe26e99fc1b 100644 > --- a/security/apparmor/mount.c > +++ b/security/apparmor/mount.c [ ... ] > @@ -423,31 +428,40 @@ int aa_mount_change_type(const struct cred *subj_cr= ed, > =20 > int aa_move_mount(const struct cred *subj_cred, > struct aa_label *label, const struct path *from_path, > - const struct path *to_path) > + const struct path *to_path, unsigned int flags) [ ... ] > - if (!our_mnt(from_path->mnt)) > - /* moving a mount detached from the namespace */ > - from_path =3D NULL; > + if ((flags & MOVE_MOUNT_T_MNTNS) && !our_mnt(to_path->mnt)) > + pflags =3D PATH_TARGET_MNTNS; > error =3D fn_for_each(label, profile, > match_mnt(profile, to_path, to_buffer, from_path, > - from_buffer, NULL, MS_MOVE, NULL, false, > - &ad)); > + from_buffer, NULL, mnt_flags, NULL, false, > + pflags, &ad)); [ ... ] > diff --git a/security/apparmor/path.c b/security/apparmor/path.c > index 2494e81015384..3443f5a868717 100644 > --- a/security/apparmor/path.c > +++ b/security/apparmor/path.c > @@ -116,14 +116,14 @@ static int d_namespace_path(const struct path *path= , char *buf, char **name, > } > =20 > /* resolve paths relative to chroot?*/ > - if (flags & PATH_CHROOT_REL) { > + if ((flags & PATH_CHROOT_REL) && !(flags & PATH_TARGET_MNTNS)) { > struct path root; > get_fs_root(current->fs, &root); > res =3D __d_path(path, &root, buf, buflen); > path_put(&root); > } else { > res =3D d_absolute_path(path, buf, buflen); > - if (!our_mnt(path->mnt)) > + if (!(flags & PATH_TARGET_MNTNS) && !our_mnt(path->mnt)) > connected =3D 0; > } > =20 > @@ -143,7 +143,7 @@ static int d_namespace_path(const struct path *path, = char *buf, char **name, > *name =3D buf; > goto out; > } > - } else if (!our_mnt(path->mnt)) > + } else if (!(flags & PATH_TARGET_MNTNS) && !our_mnt(path->mnt)) > connected =3D 0; > =20 > *name =3D res; [Severity: High] Does unconditionally setting PATH_TARGET_MNTNS bypass AppArmor's disconnected-path and chroot containment for cross-namespace MOVE_MOUNT_T_MNTNS mounts? In d_namespace_path(), PATH_TARGET_MNTNS skips PATH_CHROOT_REL lookup and suppresses connected =3D 0 for !our_mnt(path->mnt), bypassing disconnect() = and profile->disconnected prefixing without any profile opt-in. This applies to both MOVE_MOUNT_CLONE and detached-mount MOVE_MOUNT_T_MNTNS calls. Because move_mount() with MOVE_MOUNT_T_MNTNS skips may_mount() in the caller's namespace and move_mount_mntns() only checks CAP_SYS_ADMIN in target_mnt_ns->user_ns, a confined task can target an unprivileged user and mount namespace it controls. By creating a matching directory path in that namespace, d_absolute_path() resolves it to a root-relative path string that satisfies existing local-namespace mount rules. This bypasses default disconnected-path rejection, attach_disconnected.path prefixing, and chroot_relative lookup. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205032633.1702= 772-1-jarkko@kernel.org?part=3D8