mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selinux: optimize major part with a kernel config in selinux_mmap_addr()
@ 2023-07-10  8:25 Leesoo Ahn
  2023-07-17 20:13 ` Paul Moore
  2023-07-17 21:15 ` Thomas Weißschuh
  0 siblings, 2 replies; 5+ messages in thread
From: Leesoo Ahn @ 2023-07-10  8:25 UTC (permalink / raw)
  To: lsahn; +Cc: Paul Moore, Stephen Smalley, Eric Paris, selinux, linux-kernel

The major part, the conditional branch in selinux_mmap_addr() is always to be
false so long as CONFIG_LSM_MMAP_MIN_ADDR is set to zero at compile time.

This usually happens in some linux distros, for instance Ubuntu, which
the config is set to zero in release version. Therefore it could be a bit
optimized with '#if <expr>' at compile time.

Signed-off-by: Leesoo Ahn <lsahn@wewakecorp.com>
---
 security/selinux/hooks.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d06e350fedee..a049aab6524b 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3723,11 +3723,13 @@ static int selinux_mmap_addr(unsigned long addr)
 {
 	int rc = 0;
 
+#if CONFIG_LSM_MMAP_MIN_ADDR > 0
 	if (addr < CONFIG_LSM_MMAP_MIN_ADDR) {
 		u32 sid = current_sid();
 		rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
 				  MEMPROTECT__MMAP_ZERO, NULL);
 	}
+#endif
 
 	return rc;
 }
-- 
2.34.1


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

end of thread, other threads:[~2023-07-17 21:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10  8:25 [PATCH] selinux: optimize major part with a kernel config in selinux_mmap_addr() Leesoo Ahn
2023-07-17 20:13 ` Paul Moore
2023-07-17 20:31   ` Casey Schaufler
2023-07-17 20:50     ` Paul Moore
2023-07-17 21:15 ` Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®