Commit 59b9f243 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix x86-64 ptrace

From: Andi Kleen <ak@muc.de>

The EFLAGS checking was not correct.  This also fixes some problems with
32bit gdb who would sometimes make the kernel BUG.
parent 3ba6fffc
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/mm.h> #include <linux/mm.h>
/* determines which flags the user has access to. */
/* 1 = access 0 = no access */
#define FLAG_MASK 0x44dd5UL
#define R32(l,q) \ #define R32(l,q) \
case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
...@@ -70,9 +74,12 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val) ...@@ -70,9 +74,12 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
R32(eip, rip); R32(eip, rip);
R32(esp, rsp); R32(esp, rsp);
case offsetof(struct user32, regs.eflags): case offsetof(struct user32, regs.eflags): {
stack[offsetof(struct pt_regs, eflags)/8] = val & 0x44dd5; __u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8];
val &= FLAG_MASK;
*flags = val | (*flags & ~FLAG_MASK);
break; break;
}
case offsetof(struct user32, u_debugreg[4]): case offsetof(struct user32, u_debugreg[4]):
case offsetof(struct user32, u_debugreg[5]): case offsetof(struct user32, u_debugreg[5]):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment