linux-yocto/arch
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
..
alpha alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support 2025-04-10 14:30:49 +02:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:25:05 +01:00
arm ARM: 9448/1: Use an absolute path to unified.h in KBUILD_AFLAGS 2025-08-28 16:22:54 +02:00
arm64 mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-08-28 16:22:55 +02:00
c6x
csky csky, hexagon: fix broken sys_sync_file_range 2024-07-05 09:12:54 +02:00
h8300
hexagon hexagon: Fix unbalanced spinlock in die() 2025-03-13 12:46:59 +01:00
ia64 efi: ia64: move IA64-only declarations to new asm/efi.h header 2024-07-18 13:05:50 +02:00
m68k m68k: Fix lost column on framebuffer debug console 2025-08-28 16:22:48 +02:00
microblaze microblaze: don't treat zero reserved memory regions as error 2024-10-17 15:07:35 +02:00
mips lib/crypto: mips/chacha: Fix clang build and remove unneeded byteswap 2025-08-28 16:22:49 +02:00
nds32
nios2 nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults 2025-06-27 11:04:17 +01:00
openrisc openrisc: Call setup_memory() earlier in the init sequence 2024-09-04 13:17:38 +02:00
parisc parisc: Makefile: fix a typo in palo.conf 2025-08-28 16:22:48 +02:00
powerpc (powerpc/512) Fix possible dma_unmap_single() on uninitialized pointer 2025-08-28 16:22:43 +02:00
riscv riscv: Avoid fortify warning in syscall_get_arguments() 2025-05-02 07:41:02 +02:00
s390 mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-08-28 16:22:55 +02:00
sh sh: Do not use hyphen in exported variable name 2025-08-28 16:22:35 +02:00
sparc sparc/mm: disable preemption in lazy mmu mode 2025-05-02 07:40:56 +02:00
um um: vector: Reduce stack usage in vector_eth_configure() 2025-07-17 18:27:59 +02:00
x86 x86/fpu: Delay instruction pointer fixup until after warning 2025-08-28 16:22:53 +02:00
xtensa
.gitignore
Kconfig