* [PATCH AUTOSEL 6.1 47/61] riscv: mm: Take memory hotplug read-lock during kernel page table dump
[not found] <20240801002803.3935985-1-sashal@kernel.org>
@ 2024-08-01 0:26 ` Sasha Levin
0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2024-08-01 0:26 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Björn Töpel, David Hildenbrand, Oscar Salvador,
Palmer Dabbelt, Sasha Levin, paul.walmsley, palmer, aou,
alexghiti, peterlin, christophe.leroy, akpm, suagrfillet,
linux-riscv
From: Björn Töpel <bjorn@rivosinc.com>
[ Upstream commit 37992b7f1097ba79ca75ba5a26ddcf0f54f91a08 ]
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 <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20240605114100.315918-8-bjorn@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/riscv/mm/ptdump.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c
index e9090b38f8117..dbc2baa95eade 100644
--- a/arch/riscv/mm/ptdump.c
+++ b/arch/riscv/mm/ptdump.c
@@ -6,6 +6,7 @@
#include <linux/efi.h>
#include <linux/init.h>
#include <linux/debugfs.h>
+#include <linux/memory_hotplug.h>
#include <linux/seq_file.h>
#include <linux/ptdump.h>
@@ -351,7 +352,9 @@ void 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;
}
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-08-01 0:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240801002803.3935985-1-sashal@kernel.org>
2024-08-01 0:26 ` [PATCH AUTOSEL 6.1 47/61] riscv: mm: Take memory hotplug read-lock during kernel page table dump Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox