Re: [PATCH 2/3] kasan: common: use ALIGN_DOWN macro for stack alignment
From: Andrey Konovalov
Date: Mon Jul 06 2026 - 12:32:50 EST
On Sat, Jul 4, 2026 at 11:20 AM Igor Putko <igorpetindev@xxxxxxxxx> wrote:
>
> Replace the manual bitwise alignment logic in
> kasan_unpoison_task_stack_below() with the
> standard ALIGN_DOWN macro. This improves code
> readability and conforms to standard kernel idioms.
>
> Signed-off-by: Igor Putko <igorpetindev@xxxxxxxxx>
> ---
> mm/kasan/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index 34aa0fdce..5faf73c8f 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -119,7 +119,7 @@ asmlinkage void kasan_unpoison_task_stack_below(const void *watermark)
> * because this function is called by early resume code which hasn't
> * yet set up the percpu register (%gs).
> */
> - void *base = (void *)((unsigned long)watermark & ~(THREAD_SIZE - 1));
> + void *base = (void *)ALIGN_DOWN((unsigned long)watermark, THREAD_SIZE);
>
> kasan_unpoison(base, watermark - base, false);
> }
> --
> 2.47.3
>
Reviewed-by: Andrey Konovalov <andreyknvl@xxxxxxxxx>