Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()

zs_page_migrate() uses copy_page() to copy the contents of a zspage page
during migration. However, copy_page() is not instrumented by KMSAN, so
the shadow and origin metadata of the destination page are not updated.

As a result, subsequent accesses to the migrated page are reported as
use-after-free by KMSAN, despite the data being correctly copied.

Add a kmsan_copy_page_meta() call after copy_page() to propagate the KMSAN
metadata to the new page, matching what copy_highpage() does internally.

Link: https://lkml.kernel.org/r/20260321132912.93434-1-syoshida@redhat.com
Fixes: afb2d666d025 ("zsmalloc: use copy_page for full page copy")
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shigeru Yoshida and committed by
Andrew Morton
4fb61d95 1871d548

+1
+1
mm/zsmalloc.c
··· 1753 1753 */ 1754 1754 d_addr = kmap_local_zpdesc(newzpdesc); 1755 1755 copy_page(d_addr, s_addr); 1756 + kmsan_copy_page_meta(zpdesc_page(newzpdesc), zpdesc_page(zpdesc)); 1756 1757 kunmap_local(d_addr); 1757 1758 1758 1759 for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE;