Skip to contentSkip to conversation

mm-kasan-avoid-lazy-mmu-mode-hazards.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Aug 28, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/kasan: avoid lazy MMU mode hazards
has been removed from the -mm tree. Its filename was
mm-kasan-avoid-lazy-mmu-mode-hazards.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Alexander Gordeev <[email protected]>
Subject: mm/kasan: avoid lazy MMU mode hazards
Date: Mon, 18 Aug 2025 18:39:13 +0200

Functions __kasan_populate_vmalloc() and __kasan_depopulate_vmalloc() use apply_to_pte_range(), which enters lazy MMU mode. In that mode updating PTEs may not be observed until the mode is left.

That may lead to a situation in which otherwise correct reads and writes to a PTE using ptep_get(), set_pte(), pte_clear() and other access primitives bring wrong results when the vmalloc shadow memory is being (de-)populated.

To avoid these hazards leave the lazy MMU mode before and re-enter it after each PTE manipulation.

Fixes 3c5c3cfb9ef4 ("kasan: support backing vmalloc space with real shadow memory")
Cc Andrey Ryabinin <[email protected]>
Cc Daniel Axtens <[email protected]>
Cc Marc Rutland <[email protected]>
Cc Ryan Roberts <[email protected]>

---

 mm/kasan/shadow.c |    8 ++++++++
 1 file changed, 8 insertions(+)
mm/kasan/shadow.c renamed from mm/kasan/shadow.c~mm-kasan-avoid-lazy-mmu-mode-hazards +8 -0
@@ -305,6 +305,8 @@ static int kasan_populate_vmalloc_pte(pt
 	pte_t pte;
 	int index;
 
+	arch_leave_lazy_mmu_mode();
+
 	index = PFN_DOWN(addr - data->start);
 	page = data->pages[index];
 	__memset(page_to_virt(page), KASAN_VMALLOC_INVALID, PAGE_SIZE);
@@ -317,6 +319,8 @@ static int kasan_populate_vmalloc_pte(pt
 	}
 	spin_unlock(&init_mm.page_table_lock);
 
+	arch_enter_lazy_mmu_mode();
+
 	return 0;
 }
 
@@ -461,6 +465,8 @@ static int kasan_depopulate_vmalloc_pte(
 	pte_t pte;
 	int none;
 
+	arch_leave_lazy_mmu_mode();
+
 	spin_lock(&init_mm.page_table_lock);
 	pte = ptep_get(ptep);
 	none = pte_none(pte);
@@ -471,6 +477,8 @@ static int kasan_depopulate_vmalloc_pte(
 	if (likely(!none))
 		__free_page(pfn_to_page(pte_pfn(pte)));
 
+	arch_enter_lazy_mmu_mode();
+
 	return 0;
 }
 

_

Patches currently in -mm which might be from [email protected] are