mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/huge_memory: disallow raw PMD mappings of the huge zero page
@ 2026-09-17 12:10 Lance Yang
  2026-09-17 14:32 ` Kiryl Shutsemau
  2026-09-17 15:38 ` David Hildenbrand (Arm)
  0 siblings, 2 replies; 6+ messages in thread
From: Lance Yang @ 2026-09-17 12:10 UTC (permalink / raw)
  To: akpm, david
  Cc: ziy, baolin.wang, liam, nico.pache, ryan.roberts, dev.jain,
	baohua, lance.yang, usama.arif, kas, linux-mm, linux-kernel

vm_mixed_zeropage_allowed() validates zeropage insertion into
VM_MIXEDMAP VMAs. No in-tree user needs to insert the huge zero page
through vmf_insert_pfn_pmd().

Return VM_FAULT_SIGBUS if vmf_insert_pfn_pmd() is asked to map it.

Link: https://lore.kernel.org/linux-mm/f76beaf8-351a-4b22-b362-a945a5e1af6a@kernel.org/
Suggested-by: Kiryl Shutsemau <kas@kernel.org>
Suggested-by: David Hildenbrand <david@kernel.org>
Signed-off-by: Lance Yang <lance.yang@linux.dev>
---
 mm/huge_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index bfd972b997f9..c02f21ce4f4c 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1728,6 +1728,9 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, unsigned long pfn,
 						(VM_PFNMAP|VM_MIXEDMAP));
 	BUG_ON((vma->vm_flags & VM_PFNMAP) && vma_is_cow_mapping(vma));
 
+	if (unlikely(is_huge_zero_pfn(pfn)))
+		return VM_FAULT_SIGBUS;
+
 	pfnmap_setup_cachemode_pfn(pfn, &pgprot);
 
 	return insert_pmd(vma, addr, vmf->pmd, fop, pgprot, write);
-- 
2.39.3 (Apple Git-146)

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

end of thread, other threads:[~2026-09-18  2:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:10 [PATCH 1/1] mm/huge_memory: disallow raw PMD mappings of the huge zero page Lance Yang
2026-09-17 14:32 ` Kiryl Shutsemau
2026-09-17 15:29   ` David Hildenbrand (Arm)
2026-09-17 16:03     ` Kiryl Shutsemau
2026-09-18  2:52       ` Lance Yang
2026-09-17 15:38 ` David Hildenbrand (Arm)

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

all inboxes | Powered by JetHome®