* [PATCH v2] security: min_addr: use umax() to improve code
@ 2025-08-15 3:56 Qianfeng Rong
2025-08-18 19:41 ` Paul Moore
0 siblings, 1 reply; 2+ messages in thread
From: Qianfeng Rong @ 2025-08-15 3:56 UTC (permalink / raw)
To: Paul Moore, James Morris, Serge E. Hallyn, linux-security-module,
linux-kernel
Cc: Qianfeng Rong
Use umax() to reduce the code in update_mmap_min_addr() and improve its
readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
v2: Change max() to umax() and include <linux/minmax.h> explicitly.
---
security/min_addr.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/security/min_addr.c b/security/min_addr.c
index df1bc643d886..c55bb84b8632 100644
--- a/security/min_addr.c
+++ b/security/min_addr.c
@@ -3,6 +3,7 @@
#include <linux/mm.h>
#include <linux/security.h>
#include <linux/sysctl.h>
+#include <linux/minmax.h>
/* amount of vm to protect from userspace access by both DAC and the LSM*/
unsigned long mmap_min_addr;
@@ -16,10 +17,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
static void update_mmap_min_addr(void)
{
#ifdef CONFIG_LSM_MMAP_MIN_ADDR
- if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
- mmap_min_addr = dac_mmap_min_addr;
- else
- mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
+ mmap_min_addr = umax(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR);
#else
mmap_min_addr = dac_mmap_min_addr;
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] security: min_addr: use umax() to improve code
2025-08-15 3:56 [PATCH v2] security: min_addr: use umax() to improve code Qianfeng Rong
@ 2025-08-18 19:41 ` Paul Moore
0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2025-08-18 19:41 UTC (permalink / raw)
To: Qianfeng Rong, James Morris, Serge E. Hallyn,
linux-security-module, linux-kernel
Cc: Qianfeng Rong
On Aug 14, 2025 Qianfeng Rong <rongqianfeng@vivo.com> wrote:
>
> Use umax() to reduce the code in update_mmap_min_addr() and improve its
> readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> v2: Change max() to umax() and include <linux/minmax.h> explicitly.
> ---
> security/min_addr.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Merged into lsm/dev, thanks.
--
paul-moore.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-18 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15 3:56 [PATCH v2] security: min_addr: use umax() to improve code Qianfeng Rong
2025-08-18 19:41 ` Paul Moore
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).