Thread (13 messages) 13 messages, 5 authors, 2018-10-21

Re: [PATCH] powerpc: Don't print kernel instructions in show_user_instructions()

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-10-08 08:14:10

Christophe LEROY [off-list ref] writes:
Le 05/10/2018 à 15:21, Michael Ellerman a écrit :
quoted
Recently we implemented show_user_instructions() which dumps the code
...
quoted
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 913c5725cdb2..bb6ac471a784 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1306,6 +1306,16 @@ void show_user_instructions(struct pt_regs *regs)
  
  	pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int));
  
+	/*
+	 * Make sure the NIP points at userspace, not kernel text/data or
+	 * elsewhere.
+	 */
+	if (!__access_ok(pc, instructions_to_print * sizeof(int), USER_DS)) {
+		pr_info("%s[%d]: Bad NIP, not dumping instructions.\n",
+			current->comm, current->pid);
+		return;
+	}
+
This will conflict with my serie 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=64611 
which changes instructions_to_print to a constant. Will you merge it or 
do you expect me to rebase my serie ?
I can fix it up.

But I see you've already rebased it and resent, you're too quick for me :)

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help