cap_mmap_addr() sets PF_SUPERPRIV when commoncap grants CAP_SYS_RAWIO
for a mapping below vm.mmap_min_addr, before the other LSMs' mmap_addr
hooks run. If one of them then denies the mapping (e.g. SELinux's
mmap_zero check), process accounting still reports a use of privileges.
Set the flag in security_mmap_addr() once all hooks allowed the mapping,
as ns_capable() does after security_capable(). commoncap runs first and
denies such a mapping without CAP_SYS_RAWIO, so a successful hook chain
means that the capability was used.
Cc: Paul Moore <paul@paul-moore.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
Reported-by: Günther Noack <gnoack@google.com>
Closes: https://patch.msgid.link/avxjfHybQBcATFKV@google.com (local)
Fixes: 9c0d90103c7e ("Capabilities: move cap_file_mmap to commoncap.c")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118165603.2573289-1-mic@digikod.net?part=1