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=1796417875; b=MKJT+0JYHwPLqN0LPVEy1/vaJ6J0TCU0Tbdm0neoT0zKgJGDP/HIRVGI86dIXi/SqbQS RpFlABaikxc+ojArk7pXL1SkC3yggltPZdgMNrGzYS2lyvzZ+rYnKJFqfqcebxaFGiEhY TUfpLmp3w4p7Osj/5SlX82gfkLdXik/04OH7eHs/IH8eJpztcmJL0bK/0l4EIGfwdTJ1D t8kswqSz2NGS83FrAT1o5pGKI9cAPSa/mGB4DooEFBmKRirUqWEZ98lmC/y/Dwn5MvsEU /fQLFPQErmC/NKTJgeRHoDO9m4g0k1wQBnLlKWLGD1ZIV0w9KmBHUog/s0PwRrTbE/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796417875; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=m9cWObZyon3CQdgBQvZZv8MV+QKxRW1d/VPwENQ9jqU=; b=JWBH539a2B2DpEVPysa+6vhxys38fp+/ujTX0z7GniJP8gD6kUW6axfqRD34YiF5KQC8 xRniExqO09+jWXhpfsJXgtyALLJV/QBsrCdUwrmyKmxIUeck/mlDAcXSXZHbF6nxc4v4F I8E7+s+cD5d1XV5VdBWIlm4JpYhgWO4yPLedL/+ZTpOX1zsxkKs8ATa1Azpws6L1Z2Z2S oLqDc8dV0lU9m24YPkxBBjtHYLvX0Lz3dNA9a1SuAWBw+eU8VKaMyQHXCUW5rdRRPKnVH 3LQAFGF2UjFH862bcmrV47Sv+Wa7f7jbxecivIGeHMkoU5mUx6cxFBEzw25HsEhigQg== 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=ZYyiYBa2; 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 2547E606A322 for ; Fri, 4 Dec 2026 20:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZYyiYBa2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC90A1F00936 for ; Fri, 4 Dec 2026 20:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796417874; bh=m9cWObZyon3CQdgBQvZZv8MV+QKxRW1d/VPwENQ9jqU=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=ZYyiYBa2JrLGzNyptn7bjlOqgIbcUYUtJm0oJh81tZ9OFFerZjNfT45FW43EfXJSZ 2B6AoT2jj6Sk7LzO4uk7CeXsf+UlnjTnOzCpX19kJF7BrOH0bYzgO8264L5dlh1uDO doDYalfFvUVuGMfSVsVATGWOaQbG0o+732B/XvZvNjlfwdumsiUhW5GSLpL0/ZtmnR /zNpXHyOKmvWhsSrtt/Wm00haJ0R3rVBmM6phnk4a6q/H4HxdyEAmLuqSx0XONiKPK A7fjb22jpDnkvjMs9eyKVycVVzssUYB0Ia6ffvJ7G+76n5bDj3qq7DFBRr+LyudXkg Fe6onHW3W4jCQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] selinux: check FILE__MAP when rechecking remapped backing files Reply-To: sashiko-reviews@lists.linux.dev To: selinux@vger.kernel.org In-Reply-To: <20261204204354.18371-3-stephen.smalley.work@gmail.com> References: <20261204204354.18371-2-stephen.smalley.work@gmail.com> <20261204204354.18371-3-stephen.smalley.work@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 20:57:54 +0000 X-Mailing-List: selinux@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 2 potential issues to consider: - [High] selinux: missing parentheses on if map in selinux_backing_file_recheck() - [Low] selinux: duplicate FD__USE checks in selinux_backing_file_recheck() -- commit d93cc885d4fd9bb55b9bed3112dd35ed2093c015 Author: Stephen Smalley selinux: check FILE__MAP when rechecking remapped backing files This commit adds a map argument to selinux_backing_file_recheck() so that remap_file_pages() checks FILE__MAP on the user-visible file, saved mounter layers, and the lowest backing file, while mprotect() keeps its existing checks. Link: https://lore.kernel.org/lkml/CAEjxPJ5tOwBfXpqbb_pFkjtHGtrHYL_idAj=3De= s9QDGE1qPLDBA@mail.gmail.com/#r > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index c19ad72727062..f68a4a345345a 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -4149,22 +4149,43 @@ static inline int file_map_prot_check(const struc= t file *file, [ ... ] > static int selinux_backing_file_recheck(const struct file *file, > - unsigned long prot, bool shared) > + unsigned long prot, bool shared, > + bool map) > { > + u32 av =3D file_map_prot_to_av(prot, shared); > int rc; > =20 > + /* the user-visible file with the caller's credentials */ > + if (map) { > + rc =3D __file_has_perm(current_cred(), file, FILE__MAP, true); > + if (rc) > + return rc; > + } > rc =3D __file_map_prot_check(file, prot, shared, false, true); > if (rc) > return rc; > =20 > - rc =3D backing_mounters_has_perm(file, file_map_prot_to_av(prot, shared= )); > + /* every saved intermediate layer with its mounter's credentials */ > + if map > + av |=3D FILE__MAP; [Severity: High] Are parentheses missing around map here? Without them, "if map" fails to compile when CONFIG_SECURITY_SELINUX is enabled. > + rc =3D backing_mounters_has_perm(file, av); > if (rc) > return rc; > =20 > + /* the backing file itself with its mounter's credentials */ > + if (map) { > + rc =3D file_has_perm(file->f_cred, file, FILE__MAP); > + if (rc) > + return rc; > + } > return file_map_prot_check(file, prot, shared, true); > } [Severity: Low] Does calling __file_has_perm() before __file_map_prot_check() on the user-visible file, and file_has_perm() before file_map_prot_check() on the lowest backing file, evaluate FD__USE twice on each file? Both __file_has_perm() and __file_map_prot_check() check FD__USE via avc_has_perm() (and call bpf_fd_pass()). During remap_file_pages(), when the subject SID differs from the fd SID (such as after a domain transition), this emits duplicate granted audit records under auditallow. It also checks FD__USE before FILE__MAP, reversing the ordering used by selinux_mmap_file_common(). Checking FILE__MAP with inode_has_perm() to match selinux_mmap_file_common(), or folding FILE__MAP into a single __file_has_perm() call, would avoid the duplicate checks. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204204354.1837= 1-2-stephen.smalley.work@gmail.com?part=3D2