提交 f0f2d653 编写于 作者: A Andi Kleen 提交者: Linus Torvalds

[PATCH] x86_64: Implement compat functions for PTRACE_SETSIGINFO/GETSIGINFO

Previously we would just silently provide 64 bit services
for this to 32bit processes.

I also added all the other cases explicitely to the ptrace
compat wrapper to make sure this doesn't happen again.

And removed one bogus check in the wrapper.
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 f5adc9c7
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <asm/debugreg.h> #include <asm/debugreg.h>
#include <asm/i387.h> #include <asm/i387.h>
#include <asm/fpu32.h> #include <asm/fpu32.h>
#include <asm/ia32.h>
/* /*
* Determines which flags the user has access to [1 = access, 0 = no access]. * Determines which flags the user has access to [1 = access, 0 = no access].
...@@ -199,6 +200,24 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val) ...@@ -199,6 +200,24 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
#undef R32 #undef R32
static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
{
int ret;
compat_siginfo_t *si32 = (compat_siginfo_t *)compat_ptr(data);
siginfo_t *si = compat_alloc_user_space(sizeof(siginfo_t));
if (request == PTRACE_SETSIGINFO) {
ret = copy_siginfo_from_user32(si, si32);
if (ret)
return ret;
}
ret = sys_ptrace(request, pid, addr, (unsigned long)si);
if (ret)
return ret;
if (request == PTRACE_GETSIGINFO)
ret = copy_siginfo_to_user32(si32, si);
return ret;
}
asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
{ {
struct task_struct *child; struct task_struct *child;
...@@ -208,9 +227,19 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) ...@@ -208,9 +227,19 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
__u32 val; __u32 val;
switch (request) { switch (request) {
default: case PTRACE_TRACEME:
case PTRACE_ATTACH:
case PTRACE_KILL:
case PTRACE_CONT:
case PTRACE_SINGLESTEP:
case PTRACE_DETACH:
case PTRACE_SYSCALL:
case PTRACE_SETOPTIONS:
return sys_ptrace(request, pid, addr, data); return sys_ptrace(request, pid, addr, data);
default:
return -EINVAL;
case PTRACE_PEEKTEXT: case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA: case PTRACE_PEEKDATA:
case PTRACE_POKEDATA: case PTRACE_POKEDATA:
...@@ -225,10 +254,11 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) ...@@ -225,10 +254,11 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_GETFPXREGS: case PTRACE_GETFPXREGS:
case PTRACE_GETEVENTMSG: case PTRACE_GETEVENTMSG:
break; break;
}
if (request == PTRACE_TRACEME) case PTRACE_SETSIGINFO:
return ptrace_traceme(); case PTRACE_GETSIGINFO:
return ptrace32_siginfo(request, pid, addr, data);
}
child = ptrace_get_task_struct(pid); child = ptrace_get_task_struct(pid);
if (IS_ERR(child)) if (IS_ERR(child))
...@@ -349,8 +379,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) ...@@ -349,8 +379,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
break; break;
default: default:
ret = -EINVAL; BUG();
break;
} }
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册