Re: [PATCH v3] mm/codetag: clear tags before swap

From: Andrew Morton
Date: Thu Dec 12 2024 - 23:12:18 EST


On Fri, 13 Dec 2024 09:33:32 +0800 David Wang <00107082@xxxxxxx> wrote:

> When CONFIG_MEM_ALLOC_PROFILING_DEBUG is set, kernel WARN would be
> triggered when calling __alloc_tag_ref_set() during swap:
>
> alloc_tag was not cleared (got tag for mm/filemap.c:1951)
> WARNING: CPU: 0 PID: 816 at ./include/linux/alloc_tag.h...
>
> Clear code tags before swap can fix the warning. And this patch also fix
> a potential invalid address dereference in alloc_tag_add_check() when
> CONFIG_MEM_ALLOC_PROFILING_DEBUG is set and ref->ct is CODETAG_EMPTY,
> which is defined as ((void *)1).
>
> Signed-off-by: David Wang <00107082@xxxxxxx>
> Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-lkp/202412112227.df61ebb-lkp@xxxxxxxxx

This points at

51f43d5d82ed ("mm/codetag: swap tags when migrate pages"), which had
Fixes: e0a955bf7f61 ("mm/codetag: add pgalloc_tag_copy()")

e0a955bf7f61 ("mm/codetag: add pgalloc_tag_copy()") had
Fixes: dcfe378c81f7 ("lib: introduce support for page allocation tagging")
Cc: <stable@xxxxxxxxxxxxxxx>

And I'm thinking that this fix should have
Fixes: 51f43d5d82ed ("mm/codetag: swap tags when migrate pages")
Cc: <stable@xxxxxxxxxxxxxxx>