Skip to content

Commit 37992b7

Browse files
bjorn-rivospalmer-dabbelt
authored andcommitted
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 bf2b59f ("arm64/mm: Hold memory hotplug lock while walking for kernel page table dump"). Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Signed-off-by: Björn Töpel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent c75a74f commit 37992b7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/riscv/mm/ptdump.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/efi.h>
77
#include <linux/init.h>
88
#include <linux/debugfs.h>
9+
#include <linux/memory_hotplug.h>
910
#include <linux/seq_file.h>
1011
#include <linux/ptdump.h>
1112

@@ -370,7 +371,9 @@ bool ptdump_check_wx(void)
370371

371372
static int ptdump_show(struct seq_file *m, void *v)
372373
{
374+
get_online_mems();
373375
ptdump_walk(m, m->private);
376+
put_online_mems();
374377

375378
return 0;
376379
}

0 commit comments

Comments
 (0)