Re: [PATCH 3/3] kasan: common: replace magic number with KASAN_TAG_KERNEL

From: Andrey Konovalov

Date: Mon Jul 06 2026 - 11:20:25 EST


On Sat, Jul 4, 2026 at 11:20 AM Igor Putko <igorpetindev@xxxxxxxxx> wrote:
>
> Replace the literal 0xff in assign_tag()
> with KASAN_TAG_KERNEL to eliminate the
> magic number and improve code clarity.
>
> 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 5faf73c8f..3e9b6b8f5 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -188,7 +188,7 @@ static inline u8 assign_tag(struct kmem_cache *cache,
> const void *object, bool init)
> {
> if (IS_ENABLED(CONFIG_KASAN_GENERIC))
> - return 0xff;
> + return KASAN_TAG_KERNEL;

Not sure about this change either: the notion of a tag does no apply
to the Generic mode, so the code uses 0xff in such cases (the second
definition of page_kasan_tag() is another case).



>
> /*
> * If the cache neither has a constructor nor has SLAB_TYPESAFE_BY_RCU
> --
> 2.47.3
>