[PATCH 0/3] KMSAN: Move per-page metadata out of struct page
From: Muchun Song
Date: Sat Nov 14 2026 - 05:42:22 EST
This series fixes a KMSAN metadata-loss bug triggered when boot-time
gigantic HugeTLB pages initialize their page descriptors after
kmsan_init_shadow(). KMSAN currently stores each page's shadow and origin
pointers in struct page, so the later descriptor initialization loses the
metadata mappings and leaks their backing pages.
Preserving the pointers around __init_single_page() would either add
KMSAN-specific save and restore logic to the HugeTLB loop or make the
generic memmap initializer retain sanitizer-private state. Moving
kmsan_init_shadow() after HugeTLB setup is not viable either. Its metadata
comes from memblock, while gigantic page descriptors are initialized later
in page_alloc_init_late(), after memblock teardown and after the KMSAN
runtime is enabled.
Moving the metadata to page_ext is therefore part of the fix, not a
standalone refactoring. page_ext storage is independent of struct page
contents, so later descriptor initialization cannot erase the metadata and
the HugeTLB and generic memmap paths remain unaware of KMSAN.
The first two patches provide the metadata-access and early-allocation
groundwork; the final patch moves the metadata to page_ext.
Muchun Song (3):
kmsan: encapsulate per-page metadata access
mm/page_ext: support early allocation for SPARSEMEM
kmsan: fix metadata loss during HugeTLB struct page reinitialization
include/linux/kmsan.h | 3 +
include/linux/mm_types.h | 12 ----
include/linux/page_ext.h | 27 +++-----
lib/Kconfig.kmsan | 1 +
mm/Makefile | 8 +++
mm/kmsan/shadow.c | 120 +++++++++++++++++++++++++---------
mm/mm_init.c | 11 +---
mm/page_ext.c | 136 ++++++++++++++++++++++++++++++---------
8 files changed, 219 insertions(+), 99 deletions(-)
base-commit: 6ec534d64f85e949a5d58070678dcd7711875a7c
--
2.54.0