linux-yocto/arch/arm64
Anshuman Khandual 3ee9a8c27b mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd()
[ Upstream commit 59305202c6 ]

Memory hot remove unmaps and tears down various kernel page table regions
as required.  The ptdump code can race with concurrent modifications of
the kernel page tables.  When leaf entries are modified concurrently, the
dump code may log stale or inconsistent information for a VA range, but
this is otherwise not harmful.

But when intermediate levels of kernel page table are freed, the dump code
will continue to use memory that has been freed and potentially
reallocated for another purpose.  In such cases, the ptdump code may
dereference bogus addresses, leading to a number of potential problems.

To avoid the above mentioned race condition, platforms such as arm64,
riscv and s390 take memory hotplug lock, while dumping kernel page table
via the sysfs interface /sys/kernel/debug/kernel_page_tables.

Similar race condition exists while checking for pages that might have
been marked W+X via /sys/kernel/debug/kernel_page_tables/check_wx_pages
which in turn calls ptdump_check_wx().  Instead of solving this race
condition again, let's just move the memory hotplug lock inside generic
ptdump_check_wx() which will benefit both the scenarios.

Drop get_online_mems() and put_online_mems() combination from all existing
platform ptdump code paths.

Link: https://lkml.kernel.org/r/20250620052427.2092093-1-anshuman.khandual@arm.com
Fixes: bbd6ec605c ("arm64/mm: Enable memory hot remove")
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>	[s390]
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:22:55 +02:00
..
boot arm64: dts: imx8mm-beacon: Fix HS400 USDHC clock speed 2025-08-28 16:22:32 +02:00
configs
crypto
include arm64: Handle KCOV __init vs inline mismatches 2025-08-28 16:22:39 +02:00
kernel arm64/ptrace: Fix stack-out-of-bounds read in regs_get_kernel_stack_nth() 2025-06-27 11:04:25 +01:00
kvm KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE 2024-12-14 19:48:34 +01:00
lib arm64: csum: Fix OoB access in IP checksum code for negative lengths 2023-09-19 12:20:21 +02:00
mm mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-08-28 16:22:55 +02:00
net arm64: bpf: Only mitigate cBPF programs loaded by unprivileged users 2025-06-27 11:04:23 +01:00
xen xen/arm: call uaccess_ttbr0_enable for dm_op hypercall 2025-06-27 11:04:11 +01:00
Kbuild
Kconfig arm64: errata: Expand speculative SSBS workaround once more 2024-10-17 15:08:26 +02:00
Kconfig.debug
Kconfig.platforms
Makefile arm64: Force position-independent veneers 2024-11-08 16:21:58 +01:00