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=1795911070; b=KPX5RjkEYcT5W2R4aKMoNFOdgwPATQ3UE8xC333H+mx3E4Vz/qyIRtW3Pq/GTHzGlgeE Xh2zjGQHqlFyxqxvR9F2Jws3bwY0FJnpv+h+57nvLoP4rjVu6KsDeTpFMwpEj0aSgH8bI l8JxNTwSLuAUG2f313D268DP+xjeMTG3N/QozcCHs+SkFO1LzDuI30wyH5FYp8T8jFJsW LkZK0d/3N5B0gg2loAMzU1pr6lXW5JsVoI3t87HtR8zkItsBTz0XvqmDsb/5dB4/wRXvp /RwStU6Qx44itg1+aoxbX7RJj67ymlVZGE/bav0CQrI1+9lHPookkXGw7LTg49HNVoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795911070; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8T6m8x5OfcBAjrNh3r5xoitt1DJwqNhtz660bzbXerw=; b=po05JpG6/txlPG8tlz8GKR5+rSohzzjUPxKQWlx3g/yjzusGRrcnXvKlAbF2L2Qz4iVx tc4pNCcbp78MKrmyUsWTL6MuDRC9FuyxjggQ3mDWuu9iA4zKPDcH5VO06spYg/STW60Cm uvj4TzEWEu+eAhPvu+YboL+KkHkFcpZ8xpJTuS9a9aJZUId14RcNmnBPHujvm6KuU97o/ CVn8gwYdApL1/ZS4vbgtfpELSdyrNPT/9GLZe+kOnk/0bNNfZICuzRm4qAEQERdJQPera 2fnWSukOwMtPrKwfezF9H3ZDgiIquvSQe5eCMcu5cM/YS74gHlP8lPrmXMk0+oTurhQ== 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=JKsh+Sgx; 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 A7348606A325; Sun, 29 Nov 2026 00:11:10 +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=JKsh+Sgx Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF1D61F000C1; Sun, 29 Nov 2026 00:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795911070; bh=8T6m8x5OfcBAjrNh3r5xoitt1DJwqNhtz660bzbXerw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JKsh+Sgx2kUginiZ0eACv4ffq6uI6xlYSOyGQsaz2OA+HIwTfIPonsiIq/ObFFsod hrArhPtqFX3wiGUggArjwbGTn5k73aKaQaI5GlYkdY3qW/l2/OmMMQq2x5La48gikd afW3ar2Af1H/Q+rQ/IS8dASk3kzsIqkzAOqIiohvIrDVRMw+fiLDiRA4Om0XNHk9Dv 8VCHtMd18rRfBSW8pvY8u+UT8uOAIa3JZf1XWj4A4YC07/6GplE3KI/mTYk0XW3J+I W06i/8+AuIjGeL6YE6jySadH9TzByOkXTWLuTR97an2/Zk0WowtacG4vryi+q2TnFV HftrmNTlGTBPg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v8 09/29] 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" , "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-10-jarkko@kernel.org> References: <20261128235808.2369970-1-jarkko@kernel.org> <20261128235808.2369970-10-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 00:11:08 +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: aa_move_mount() fails with -EACCES on foreign target_mnt_ns to_path -- commit 0fe740e3c444486594296da1a53a300752de0fc2 Author: Jarkko Sakkinen apparmor: Mediate MOVE_MOUNT_CLONE as recursive bind This commit passes move_mount() flags through aa_move_mount() and maps MOVE_MOUNT_CLONE to MS_BIND | MS_REC while keeping from_path so AppArmor checks both source and destination paths against recursive bind rules. > diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c > index 4ed7b9136bebf..8d3db6bfdfb61 100644 > --- a/security/apparmor/mount.c > +++ b/security/apparmor/mount.c > @@ -423,13 +423,15 @@ 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) > { > struct aa_profile *profile; > char *to_buffer =3D NULL, *from_buffer =3D NULL; > + unsigned long mnt_flags =3D (flags & MOVE_MOUNT_CLONE) ? > + (MS_BIND | MS_REC) : MS_MOVE; > int error; > DEFINE_AUDIT_MOUNT(ad, OP_MOUNT, subj_cred); > - ad.mnt.flags =3D MS_MOVE; > + ad.mnt.flags =3D mnt_flags; > =20 > AA_BUG(!label); > AA_BUG(!from_path); > @@ -441,12 +443,12 @@ int aa_move_mount(const struct cred *subj_cred, > if (!to_buffer || !from_buffer) > goto out; > =20 > - if (!our_mnt(from_path->mnt)) > + if (!(flags & MOVE_MOUNT_CLONE) && !our_mnt(from_path->mnt)) > /* moving a mount detached from the namespace */ > from_path =3D NULL; > error =3D fn_for_each(label, profile, > match_mnt(profile, to_path, to_buffer, from_path, > - from_buffer, NULL, MS_MOVE, NULL, false, > + from_buffer, NULL, mnt_flags, NULL, false, > &ad)); [Severity: High] Does match_mnt() fail with -EACCES on to_path for every valid MOVE_MOUNT_CLONE call when the profile does not set attach_disconnected? move_mount() only allows MOVE_MOUNT_CLONE together with MOVE_MOUNT_T_MNTNS, where move_mount_mntns() resolves to_path in target_mnt_ns, and do_move_mount() requires from_path to be in the caller's mount namespace while target_mnt_ns is a different mount namespace: fs/namespace.c:do_move_mount() { ... case MNT_TREE_CLONE: if (!check_mnt(old) || old->mnt_ns =3D=3D target_mnt_ns || (old->mnt.mnt_sb->s_flags & SB_NOUSER)) return -EINVAL; ... } Because to_path->mnt belongs to target_mnt_ns, our_mnt(to_path->mnt) is always false in match_mnt() -> match_mnt_path_str() -> aa_path_name() -> d_namespace_path(). Without PATH_CONNECT_PATH, disconnect() returns -EACCES ("Failed name lookup - disconnected path") and match_mnt_path_str() aborts via aa_audit_perm_error() before do_match_mnt() is ever reached to evaluate recursive bind rules. Also, because a valid MOVE_MOUNT_CLONE requires check_mnt(old), our_mnt(from_path->mnt) is already true for valid calls, so gating !our_mnt(from_path->mnt) with !(flags & MOVE_MOUNT_CLONE) only changes behavior for invalid detached or foreign source mounts that do_move_mount() will reject with -EINVAL. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128235808.2369= 970-1-jarkko@kernel.org?part=3D9