linux/security/selinux
Ondrej Mosnacek 9fe595fad5 selinux: fix incorrect execmem checks on overlayfs
The commit fixing the overlayfs mmap() and mprotect() access checks
failed to skip the execmem check in __file_map_prot_check() for the case
where the "mounter check" is being performed. This check should be
performed only against the credentials of the task that is calling
mmap()/mprotect(), since it doesn't pertain to the file itself, but
rather just gates the ability of the calling task to get an executable
memory mapping in general.

The purpose of the "mounter check" is to guard against using an
overlayfs mount to gain file access that would otherwise be denied to
the mounter. For execmem this is not relevant, as there is no further
file access granted based on it (notice that the file's context is not
used as the target in the check), so checking it also against the
mounter credentials would be incorrect.

Fix this by passing a boolean to [__]file_map_prot_check() and
selinux_mmap_file_common() that indicates if we are doing the "mounter
check" and skiping the execmem check in that case. Since this boolean
also indicates if we use current_cred() or the mounter cred as the
subject, also remove the "cred" argument from these functions and
determine it based on the boolean and the file struct.

Cc: stable@vger.kernel.org
Fixes: 82544d36b1 ("selinux: fix overlayfs mmap() and mprotect() access checks")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2026-07-14 18:10:20 -04:00
..
include selinux/stable-7.2 PR 20260615 2026-06-17 12:41:00 +01:00
ss selinux/stable-7.2 PR 20260615 2026-06-17 12:41:00 +01:00
.gitignore selinux: move genheaders to security/selinux/ 2024-10-03 16:07:51 -04:00
avc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
genheaders.c selinux: move genheaders to security/selinux/ 2024-10-03 16:07:51 -04:00
hooks.c selinux: fix incorrect execmem checks on overlayfs 2026-07-14 18:10:20 -04:00
ibpkey.c selinux: comment spelling fix in ibpkey.c 2026-05-27 20:10:48 -04:00
ima.c selinux: adjust typos in comments 2023-05-08 16:44:01 -04:00
initcalls.c selinux: move initcalls to the LSM framework 2025-10-22 19:24:28 -04:00
Kconfig selinux: Introduce a new config to make avc cache slot size adjustable 2025-10-23 18:24:30 -04:00
Makefile selinux: move initcalls to the LSM framework 2025-10-22 19:24:28 -04:00
netif.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
netlabel.c lsm/stable-6.12 PR 20240911 2024-09-16 18:19:47 +02:00
netlink.c selinux: move initcalls to the LSM framework 2025-10-22 19:24:28 -04:00
netnode.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
netport.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
nlmsgtab.c xfrm: add XFRM_MSG_MIGRATE_STATE for single SA migration 2026-06-04 12:22:47 +02:00
selinuxfs.c selinux/stable-7.2 PR 20260615 2026-06-17 12:41:00 +01:00
status.c selinux: avoid implicit conversions regarding enforcing status 2023-07-18 18:29:50 -04:00
xfrm.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00