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 B2E71606A322 for ; Sat, 5 Dec 2026 03:51:52 +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 kanga.kvack.org (Postfix) id AA44B6B05B4; Fri, 4 Dec 2026 22:51:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A7B6E6B05B8; Fri, 4 Dec 2026 22:51:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96A686B05B9; Fri, 4 Dec 2026 22:51:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 63D506B05B4 for ; Fri, 4 Dec 2026 22:51:46 -0500 (EST) Received: from smtpin15.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E072F405B7 for ; Sat, 5 Dec 2026 03:51:45 +0000 (UTC) X-FDA: 85508555370.15.0773AD9 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf30.hostedemail.com (Postfix) with ESMTP id 406EE80007 for ; Sat, 5 Dec 2026 03:51:44 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=RL+jCVxc; spf=pass (imf30.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 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=1796442704; b=st8IKxLhspWAiSlwg63J9SsSBoLZJaPDpYG3sPYW7iaTqjbMZX8CjxIV/BIb11CHTcGd0c wCQqlfEH+qPiKZCWylhJ+RDQcxyy5njmHP1kNnV5amiLfbS+T7ZB3XtVIwwgzTpJR/Qfay tryL758OQvDA7pc/ZFTww46B+JyhrqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796442704; 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=v+catJ+o6PB0WBkdXWPw+EDyFP57wmMY1zhVMpocFog=; b=Vy9F4CMIpzj2hXcY35Ex7XflCx+9bs5dDCIYHE8PTpZfIc7SZ9SmRZGORXOgY0tiLtOMOl dp1ytqwrh5IQ6GADkSlKtmmYsCz31cG9XHoiT5tlzZ9NA8toOHvU5TX7oCXm3+fVDSjElf 7BVyS8OTNdU5VwLIFPTonfCicUc3qAI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=RL+jCVxc; spf=pass (imf30.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 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 sea.source.kernel.org (Postfix) with ESMTP id 5E93945A9C; Sat, 5 Dec 2026 03:51:43 +0000 (UTC) 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-Stat-Signature: f3br5xmycrdfi69ucwxanxddy7scmi9j X-Rspam-User: 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-Rspamd-Queue-Id: 406EE80007 X-Rspamd-Server: rspam01 X-HE-Tag: 1796442704-708468 X-HE-Meta: U2FsdGVkX18ae+ydnN4OoFzEWAwYgwqyTp0LAyhOXLX0utRz0LozK07nKTLwHHjaF3t6JUhqMwpZSSjibno9tW//ive2h8MtUSakqIDgKqjQxmbhWAM3JZWvUuUoa3ydQIGUXwZMLAcX8EMIGvjYz7Q9a6gW1kW9mONxAs6iZivlM2vEbBFzVAyhUnKY8A0z7TgFxSS4n4VSP6hXxIbzIFjpBekmHoO2hu+duMDJNdaR+I+VQ3JvaISk927zFLoCp4eJ880NMq4pHNNgM4rL7G1fEDJOSCNs5s2HwCbfyXcUGhVA4Edr1sXYQq2v55nGaJnJ8Uvjz6r45Ion+FKMkYdG5cgOhhxcTnjBRseiH1APt6cK6KlLkzWNNDBgrem6GOIm5XbqizDwayViG9cdVqnOkTIvqD5qGGGtNfnP/P6dgoNZGbtsVP2G+TzP6YEjaYCQe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ezZMbUWIVCoN3+fbU2Uff3K0BMUdKHJ1DOWjCpRSi06e/DCToIfBick4excqfZ++/SUX5k5SbyDta5F1ODZ2z7f+357Dr4FN59ePEuZaOOeFbO3f1hq4X63/+HZUFJNMvrJH/mQd0Amr91nKbezabZHjAF/Db4W5Wm5ipNzKkhNEOS1MgHwFUC1OZq//a9aHjCp5zqWy85tKy1rjdOLP3gaWBlnsOYX7QpyL8Y+cAWWSUhTnwKRnecCmwYJvZQuA9r/C5DdS3CLA6fb3wmysTO06Glxf33z2PgF1fvIU6/cTbA7PcLdDz0/8Oo01YjmFoD7UQHySShrhs446bJB6dz5ESo0ccHIEubUbxGvZQso3hzSnWQy+v7YYyoWGhVAEsv8eaBY7q73v3FcI3L7lKA6g== 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] 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