Re: [PATCH] mm/mseal: use min/max in mseal_apply

From: Lorenzo Stoakes

Date: Tue May 05 2026 - 06:51:50 EST


On Sun, May 03, 2026 at 01:59:16PM +0200, Thorsten Blum wrote:
> Use the type-checked min()/max() macros instead of MIN()/MAX(), which
> are supposed to be used "for obvious constants only".
>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>

Oops my bad :)

LGTM, so:

Reviewed-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

> ---
> mm/mseal.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mseal.c b/mm/mseal.c
> index e2093ae3d25c..9781647483d1 100644
> --- a/mm/mseal.c
> +++ b/mm/mseal.c
> @@ -8,6 +8,7 @@
> */
>
> #include <linux/mempolicy.h>
> +#include <linux/minmax.h>
> #include <linux/mman.h>
> #include <linux/mm.h>
> #include <linux/mm_inline.h>
> @@ -65,8 +66,8 @@ static int mseal_apply(struct mm_struct *mm,
> prev = vma;
>
> for_each_vma_range(vmi, vma, end) {
> - const unsigned long curr_start = MAX(vma->vm_start, start);
> - const unsigned long curr_end = MIN(vma->vm_end, end);
> + const unsigned long curr_start = max(vma->vm_start, start);
> + const unsigned long curr_end = min(vma->vm_end, end);
>
> if (!vma_test(vma, VMA_SEALED_BIT)) {
> vma_flags_t vma_flags = vma->flags;