linux/arch/arm64/mm
Dev Jain f73a8edc2c arm64: make huge_ptep_get handled unaligned addresses
huge_ptep_get() can be handed a virtual address pointing to the middle
of a contpmd/contpte mapped hugetlb folio (examples of callers are
pagemap_hugetlb_range, page_mapped_in_vma).

The arm64 helper rewalks the pgtables in find_num_contig to answer
whether the huge pte we have maps a contpmd or a contpte hugetlb folio,
and returns CONT_PMDS or CONT_PTES, so that it can collect a/d bits over
the contiguous ptes. We can falsely return CONT_PTES instead of
CONT_PMDS if the addr is not aligned. On systems where CONT_PTES !=
CONT_PMDS (meaning page size is 16K), we could collect excess A/D bit
state, meaning extra work for the kernel. Even worse, we may iterate
beyond the PTE table and dereference a garbage ptep pointer to access
physical memory we don't own. Since the ptep pointer is a linear map
address, we may run off the end of the linear map or into a hole,
dereference a VA not mapped into the kernel pgtables and cause kernel
panic.

Fix this by aligning the pmdp pointer down to a contpmd base before
checking equality with the passed huge pte pointer, to correctly answer
whether the huge pte is the base of a contpmd block.

Fixes: 29cb805196 ("arm64: hugetlb: Cleanup huge_pte size discovery mechanisms")
Cc: stable@vger.kernel.org
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Dev Jain <dev.jain@arm.com>
Acked-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Will Deacon <will@kernel.org>
2026-07-22 11:44:47 +00:00
..
cache.S arm64: Provide dcache_inval_poc_nosync helper 2026-03-13 23:47:16 +01:00
context.c arm64/mm: Directly use TTBRx_EL1_CnP 2026-03-14 16:12:27 +00:00
contpte.c mm.git review status for linus..mm-stable 2026-04-15 12:59:16 -07:00
copypage.c arm64: mte: Do not warn if the page is already tagged in copy_highpage() 2025-10-23 17:34:58 +01:00
dma-mapping.c driver core: Replace dev->dma_coherent with dev_dma_coherent() 2026-04-26 23:43:58 +02:00
extable.c arm64: mm: Handle PAN faults on uaccess CPY* instructions 2025-03-07 18:28:29 +00:00
fault.c arm64: mm: When logging data aborts only decode Xs when ISV=1 2026-07-16 16:11:13 +01:00
fixmap.c arm64: Rename page table BSS section to .bss..pgtbl 2026-06-05 11:44:09 +01:00
flush.c mm: introduce memdesc_flags_t 2025-09-13 16:55:07 -07:00
gcs.c arm64: gcs: use the new common vm_mmap_shadow_stack() helper 2026-04-05 13:53:05 -07:00
hugetlbpage.c arm64: make huge_ptep_get handled unaligned addresses 2026-07-22 11:44:47 +00:00
init.c memblock: updates for 7.0-rc1 2026-04-18 11:29:14 -07:00
ioremap.c arm64: io: Rename ioremap_prot() to __ioremap_prot() 2026-02-25 19:49:51 +00:00
kasan_init.c arm64: Rename page table BSS section to .bss..pgtbl 2026-06-05 11:44:09 +01:00
Makefile mm: rename GENERIC_PTDUMP and PTDUMP_CORE 2025-03-17 00:05:32 -07:00
mem_encrypt.c arm64: mm: Add top-level dispatcher for internal mem_encrypt API 2024-08-30 16:30:41 +01:00
mmap.c arm64/mm: Rename ptdesc_t 2026-06-05 11:44:36 +01:00
mmu.c arm64/mm: Check the requested PFN range during memory removal 2026-07-21 15:21:11 +00:00
mteswap.c arm64: mm: swap: support THP_SWAP on hardware with MTE 2024-04-25 20:56:07 -07:00
pageattr.c arm64/mm: Rename ptdesc_t 2026-06-05 11:44:36 +01:00
pgd.c arm64/mm: Ensure PGD_SIZE is aligned to 64 bytes when PA_BITS = 52 2025-11-11 19:13:03 +00:00
physaddr.c arm64: mm: Don't use %pK through printk 2025-03-20 15:34:53 +00:00
proc.S arm64 updates for 7.0 2026-02-09 20:28:45 -08:00
ptdump_debugfs.c mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-07-09 22:42:20 -07:00
ptdump.c arm64/mm: Rename ptdesc_t 2026-06-05 11:44:36 +01:00
trans_pgd-asm.S arm64: kexec: configure EL2 vectors for kexec 2021-10-01 13:31:00 +01:00
trans_pgd.c arm64: mm: Handle invalid large leaf mappings correctly 2026-04-02 20:49:16 +01:00