]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
ima: Align ima_file_mmap() parameters with mmap_file LSM hook
authorRoberto Sassu <roberto.sassu@huawei.com>
Tue, 31 Jan 2023 17:42:43 +0000 (18:42 +0100)
committerMimi Zohar <zohar@linux.ibm.com>
Tue, 31 Jan 2023 18:08:38 +0000 (13:08 -0500)
commit4971c268b85e1c7a734a61622fc0813c86e2362e
tree262652c6ee343bedebd7bffa3bc00c6113c2cf00
parent8250865c164e3ddb930953523c93b3c821bdd322
ima: Align ima_file_mmap() parameters with mmap_file LSM hook

Commit 98de59bfe4b2f ("take calculation of final prot in
security_mmap_file() into a helper") moved the code to update prot, to be
the actual protections applied to the kernel, to a new helper called
mmap_prot().

However, while without the helper ima_file_mmap() was getting the updated
prot, with the helper ima_file_mmap() gets the original prot, which
contains the protections requested by the application.

A possible consequence of this change is that, if an application calls
mmap() with only PROT_READ, and the kernel applies PROT_EXEC in addition,
that application would have access to executable memory without having this
event recorded in the IMA measurement list. This situation would occur for
example if the application, before mmap(), calls the personality() system
call with READ_IMPLIES_EXEC as the first argument.

Align ima_file_mmap() parameters with those of the mmap_file LSM hook, so
that IMA can receive both the requested prot and the final prot. Since the
requested protections are stored in a new variable, and the final
protections are stored in the existing variable, this effectively restores
the original behavior of the MMAP_CHECK hook.

Cc: stable@vger.kernel.org
Fixes: 98de59bfe4b2 ("take calculation of final prot in security_mmap_file() into a helper")
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
include/linux/ima.h
security/integrity/ima/ima_main.c
security/security.c