summaryrefslogtreecommitdiffstats
path: root/arch/nds32/kernel
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-07-20 13:44:48 +0200
committerGreentime Hu <green.hu@gmail.com>2021-02-25 14:31:49 +0800
commitfa2f478a348efa483abd4159c9f5478a3867bcc0 (patch)
tree47b069b6b4e341d94e8613add84dcc5af198cc11 /arch/nds32/kernel
parent9d63fecfcb2c7d379b6dd06892c534068a03a470 (diff)
downloadlinux-fa2f478a348efa483abd4159c9f5478a3867bcc0.tar.bz2
nds32: use get_kernel_nofault in dump_mem
Use the proper get_kernel_nofault helper to access an unsafe kernel pointer without faulting instead of playing with set_fs and get_user. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Nick Hu <nickhu@andestech.com> Acked-by: Greentime Hu <green.hu@gmail.com> Signed-off-by: Greentime Hu <green.hu@gmail.com>
Diffstat (limited to 'arch/nds32/kernel')
-rw-r--r--arch/nds32/kernel/traps.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c
index b66f889bc6df..ee0d9ae192a5 100644
--- a/arch/nds32/kernel/traps.c
+++ b/arch/nds32/kernel/traps.c
@@ -25,17 +25,8 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr);
void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
{
unsigned long first;
- mm_segment_t fs;
int i;
- /*
- * We need to switch to kernel mode so that we can use __get_user
- * to safely read from kernel space. Note that we now dump the
- * code first, just in case the backtrace kills us.
- */
- fs = get_fs();
- set_fs(KERNEL_DS);
-
pr_emerg("%s(0x%08lx to 0x%08lx)\n", lvl, bottom, top);
for (first = bottom & ~31; first < top; first += 32) {
@@ -48,7 +39,9 @@ void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {
if (p >= bottom && p < top) {
unsigned long val;
- if (__get_user(val, (unsigned long *)p) == 0)
+
+ if (get_kernel_nofault(val,
+ (unsigned long *)p) == 0)
sprintf(str + i * 9, " %08lx", val);
else
sprintf(str + i * 9, " ????????");
@@ -56,8 +49,6 @@ void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
}
pr_emerg("%s%04lx:%s\n", lvl, first & 0xffff, str);
}
-
- set_fs(fs);
}
EXPORT_SYMBOL(dump_mem);