public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* + mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch added to mm-new branch
@ 2026-03-21 17:50 Andrew Morton
  2026-03-25  1:46 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2026-03-21 17:50 UTC (permalink / raw)
  To: mm-commits, stable, senozhatsky, minchan, mark-pk.tsai, syoshida,
	akpm


The patch titled
     Subject: mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()
has been added to the -mm mm-new branch.  Its filename is
     mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Shigeru Yoshida <syoshida@redhat.com>
Subject: mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()
Date: Sat, 21 Mar 2026 22:29:11 +0900

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>
Cc: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/zsmalloc.c |    1 +
 1 file changed, 1 insertion(+)

--- a/mm/zsmalloc.c~mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate
+++ a/mm/zsmalloc.c
@@ -1753,6 +1753,7 @@ static int zs_page_migrate(struct page *
 	 */
 	d_addr = kmap_local_zpdesc(newzpdesc);
 	copy_page(d_addr, s_addr);
+	kmsan_copy_page_meta(zpdesc_page(newzpdesc), zpdesc_page(zpdesc));
 	kunmap_local(d_addr);
 
 	for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE;
_

Patches currently in -mm which might be from syoshida@redhat.com are

mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch added to mm-new branch
  2026-03-21 17:50 + mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch added to mm-new branch Andrew Morton
@ 2026-03-25  1:46 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-03-25  1:46 UTC (permalink / raw)
  To: Andrew Morton
  Cc: mm-commits, stable, senozhatsky, minchan, mark-pk.tsai, syoshida

On (26/03/21 10:50), Andrew Morton wrote:
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch
> 
[..]
> ------------------------------------------------------
> From: Shigeru Yoshida <syoshida@redhat.com>
> Subject: mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()
> Date: Sat, 21 Mar 2026 22:29:11 +0900
> 
> 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>
> Cc: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-25  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 17:50 + mm-zsmalloc-copy-kmsan-metadata-in-zs_page_migrate.patch added to mm-new branch Andrew Morton
2026-03-25  1:46 ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox