[PATCH] Check for canonical addresses in ptrace

Linux Kernel Mailing List <[email protected]> Thu, 30 Jun 2005 22:45:17 -0700
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
tree 59db26d5f182bd694a3a0b038507509ef3e5e8f2
parent 1e483bdd0ac8852a53e32e09059df9788619b3e8
author Andi Kleen <[email protected]> Tue, 28 Jun 2005 15:17:29 +0200
committer Marcelo Tosatti <[email protected]> Wed, 29 Jun 2005 16:49:53 -0300

[PATCH] Check for canonical addresses in ptrace

Check for canonical addresses in ptrace

This works around a AMD bug that allows to hang the CPU by passing
illegal addresses.

Signed-off-by: Andi Kleen <[email protected]>

 arch/x86_64/kernel/ptrace.c |    5 +++++
 1 files changed, 5 insertions(+)

diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -139,6 +139,11 @@ static int putreg(struct task_struct *ch
 				return -EIO;
 			value &= 0xffff;
             break;
+		case offsetof(struct user_regs_struct, rip):
+			/* Check if the new RIP address is canonical */
+			if (value >= TASK_SIZE)
+				return -EIO;
+			break;
 	}      
 	put_stack_long(child, regno - sizeof(struct pt_regs), value);
 	return 0;