linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] security: Restore passing final prot to ima_file_mmap()
@ 2022-12-21 14:10 Roberto Sassu
  2023-01-06 21:14 ` Paul Moore
  0 siblings, 1 reply; 11+ messages in thread
From: Roberto Sassu @ 2022-12-21 14:10 UTC (permalink / raw)
  To: paul, jmorris, serge, zohar
  Cc: linux-integrity, linux-security-module, linux-kernel, viro,
	Roberto Sassu, stable

From: Roberto Sassu <roberto.sassu@huawei.com>

Commit 98de59bfe4b2f ("take calculation of final prot in
security_mmap_file() into a helper") moved the code to update prot with the
actual protection flags to be granted to the requestor by the kernel to a
helper called mmap_prot(). However, the patch didn't update the argument
passed to ima_file_mmap(), making it receive the requested prot instead of
the final computed prot.

A possible consequence is that files mmapped as executable might not be
measured/appraised if PROT_EXEC is not requested but subsequently added in
the final prot.

Replace prot with mmap_prot(file, prot) as the second argument of
ima_file_mmap() to restore the original behavior.

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>
---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/security.c b/security/security.c
index d1571900a8c7..0d2359d588a1 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1666,7 +1666,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
 					mmap_prot(file, prot), flags);
 	if (ret)
 		return ret;
-	return ima_file_mmap(file, prot);
+	return ima_file_mmap(file, mmap_prot(file, prot));
 }
 
 int security_mmap_addr(unsigned long addr)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-01-23 21:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 14:10 [PATCH v2] security: Restore passing final prot to ima_file_mmap() Roberto Sassu
2023-01-06 21:14 ` Paul Moore
2023-01-11  9:30   ` Roberto Sassu
2023-01-11 14:25     ` Paul Moore
2023-01-12 12:36       ` Roberto Sassu
2023-01-12 17:45         ` Mimi Zohar
2023-01-13 10:52           ` Roberto Sassu
2023-01-20 21:04             ` Paul Moore
2023-01-23  8:30               ` Roberto Sassu
2023-01-23 21:03                 ` Paul Moore
2023-01-22 20:29             ` Mimi Zohar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).