From: Björn Töpel Date: Wed, 5 Jun 2024 11:40:50 +0000 (+0200) Subject: riscv: mm: Take memory hotplug read-lock during kernel page table dump X-Git-Tag: v6.11-rc1~94^2~7^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37992b7f1097ba79ca75ba5a26ddcf0f54f91a08;p=thirdparty%2Fkernel%2Flinux.git riscv: mm: Take memory hotplug read-lock during kernel page table dump During memory hot remove, the ptdump functionality can end up touching stale data. Avoid any potential crashes (or worse), by holding the memory hotplug read-lock while traversing the page table. This change is analogous to arm64's commit bf2b59f60ee1 ("arm64/mm: Hold memory hotplug lock while walking for kernel page table dump"). Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel Link: https://lore.kernel.org/r/20240605114100.315918-8-bjorn@kernel.org Signed-off-by: Palmer Dabbelt --- diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index 1289cc6d3700c..9d5f657a251b3 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -370,7 +371,9 @@ bool ptdump_check_wx(void) static int ptdump_show(struct seq_file *m, void *v) { + get_online_mems(); ptdump_walk(m, m->private); + put_online_mems(); return 0; }