Skip to contentSkip to conversation

m68k: use get_kernel_nofault in show_registers

PATCH In review Christoph Hellwig 2 participants 2 messages Jul 20, 2020 – Aug 26, 2020 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: use get_kernel_nofault in show_registers

Use the proper get_kernel_nofault helper to access an unsafe kernel pointer without faulting instead of playing with set_fs and get_user.

---
 arch/m68k/kernel/traps.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/m68k/kernel/traps.c +1 -4
index df6fc782754f73..c265355fa244d4 100644
@@ -846,7 +846,6 @@ static void show_trace(unsigned long *stack, const char *loglvl)
 void show_registers(struct pt_regs *regs)
 {
 	struct frame *fp = (struct frame *)regs;
-	mm_segment_t old_fs = get_fs();
 	u16 c, *cp;
 	unsigned long addr;
 	int i;
@@ -919,10 +918,9 @@ void show_registers(struct pt_regs *regs)
 	show_stack(NULL, (unsigned long *)addr, KERN_INFO);
 
 	pr_info("Code:");
-	set_fs(KERNEL_DS);
 	cp = (u16 *)regs->pc;
 	for (i = -8; i < 16; i++) {
-		if (get_user(c, cp + i) && i >= 0) {
+		if (get_kernel_nofault(c, cp + i) && i >= 0) {
 			pr_cont(" Bad PC value.");
 			break;
 		}
@@ -931,7 +929,6 @@ void show_registers(struct pt_regs *regs)
 		else
 			pr_cont(" <%04x>", c);
 	}
-	set_fs(old_fs);
 	pr_cont("\n");
 }
 
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christoph Hellwig

Use the proper get_kernel_nofault helper to access an unsafe kernel pointer without faulting instead of playing with set_fs and get_user.

i.e. applied, and queued in the m68k for-v5.10 branch.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds