[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8ab2084cc35ddc9f2a4796ff7cd88954@paul-moore.com>
Date: Thu, 14 Aug 2025 22:17:46 -0400
From: Paul Moore <paul@...l-moore.com>
To: Qianfeng Rong <rongqianfeng@...o.com>, James Morris <jmorris@...ei.org>, "Serge E. Hallyn" <serge@...lyn.com>, linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Qianfeng Rong <rongqianfeng@...o.com>
Subject: Re: [PATCH] security: min_addr: use max() to improve code
On Aug 14, 2025 Qianfeng Rong <rongqianfeng@...o.com> wrote:
>
> Use max() to reduce the code in update_mmap_min_addr() and improve its
> readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>
> ---
> security/min_addr.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/security/min_addr.c b/security/min_addr.c
> index df1bc643d886..50035bc9281c 100644
> --- a/security/min_addr.c
> +++ b/security/min_addr.c
> @@ -16,10 +16,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 = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR);
It seems like the umax() macro would be a better choice here, yes?
It might also be a good idea to explicitly include the
include/linux/minmax.h header in this file.
> #else
> mmap_min_addr = dac_mmap_min_addr;
> #endif
> --
> 2.34.1
--
paul-moore.com
Powered by blists - more mailing lists