Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()" failed to apply to 6.12-stable tree

PATCH New [email protected] 2 participants 2 messages May 1

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 4fb61d95ad21c3b6f1c09f357ff49d70abb0535e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050105-tremor-wispy-7169@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 4fb61d95ad21c3b6f1c09f357ff49d70abb0535e Mon Sep 17 00:00:00 2001
From: Shigeru Yoshida <[email protected]>
Date: Sat, 21 Mar 2026 22:29:11 +0900
Subject: [PATCH] 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.

Fixes afb2d666d025 ("zsmalloc: use copy_page for full page copy")
Cc Mark-PK Tsai <[email protected]>
Cc Minchan Kim <[email protected]>
mm/zsmalloc.c +1 -0
index e7417ece1c12..63128ddb7959 100644
@@ -1753,6 +1753,7 @@ static int zs_page_migrate(struct page *newpage, struct page *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;
maintainer
#1 lore raw

PATCH 1/1 mm/zsmalloc: copy KMSAN metadata in zs_page_migrate()

From: Shigeru Yoshida <[email protected]>

[ Upstream commit 4fb61d95ad21c3b6f1c09f357ff49d70abb0535e ]

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.

Fixes afb2d666d025 ("zsmalloc: use copy_page for full page copy")
Cc Mark-PK Tsai <[email protected]>
Cc Minchan Kim <[email protected]>
[ translated zpdesc_page(newzpdesc/zpdesc) arguments to newpage/page ]
---
 mm/zsmalloc.c | 1 +
 1 file changed, 1 insertion(+)
mm/zsmalloc.c +1 -0
index e4326af00e5eb..76adbce8d42b9 100644
@@ -1808,6 +1808,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
 	 */
 	d_addr = kmap_atomic(newpage);
 	copy_page(d_addr, s_addr);
+	kmsan_copy_page_meta(newpage, page);
 	kunmap_atomic(d_addr);
 
 	for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE;
Signature · 1 line
2.53.0