x86: clean up arch/x86/ia32/ptrace32.c
White space and coding style clenaup. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
2da06b4e5d
commit
5de15d42e4
@@ -5,8 +5,8 @@
|
||||
* Some parts copied from arch/i386/kernel/ptrace.c. See that file for earlier
|
||||
* copyright.
|
||||
*
|
||||
* This allows to access 64bit processes too; but there is no way to see the extended
|
||||
* register contents.
|
||||
* This allows to access 64bit processes too; but there is no way to
|
||||
* see the extended register contents.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@@ -36,7 +36,8 @@
|
||||
#define FLAG_MASK 0x54dd5UL
|
||||
|
||||
#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
|
||||
|
||||
static int putreg32(struct task_struct *child, unsigned regno, u32 val)
|
||||
{
|
||||
@@ -45,26 +46,31 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
|
||||
|
||||
switch (regno) {
|
||||
case offsetof(struct user32, regs.fs):
|
||||
if (val && (val & 3) != 3) return -EIO;
|
||||
if (val && (val & 3) != 3)
|
||||
return -EIO;
|
||||
child->thread.fsindex = val & 0xffff;
|
||||
break;
|
||||
case offsetof(struct user32, regs.gs):
|
||||
if (val && (val & 3) != 3) return -EIO;
|
||||
if (val && (val & 3) != 3)
|
||||
return -EIO;
|
||||
child->thread.gsindex = val & 0xffff;
|
||||
break;
|
||||
case offsetof(struct user32, regs.ds):
|
||||
if (val && (val & 3) != 3) return -EIO;
|
||||
if (val && (val & 3) != 3)
|
||||
return -EIO;
|
||||
child->thread.ds = val & 0xffff;
|
||||
break;
|
||||
case offsetof(struct user32, regs.es):
|
||||
child->thread.es = val & 0xffff;
|
||||
break;
|
||||
case offsetof(struct user32, regs.ss):
|
||||
if ((val & 3) != 3) return -EIO;
|
||||
if ((val & 3) != 3)
|
||||
return -EIO;
|
||||
stack[offsetof(struct pt_regs, ss)/8] = val & 0xffff;
|
||||
break;
|
||||
case offsetof(struct user32, regs.cs):
|
||||
if ((val & 3) != 3) return -EIO;
|
||||
if ((val & 3) != 3)
|
||||
return -EIO;
|
||||
stack[offsetof(struct pt_regs, cs)/8] = val & 0xffff;
|
||||
break;
|
||||
|
||||
@@ -81,6 +87,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
|
||||
|
||||
case offsetof(struct user32, regs.eflags): {
|
||||
__u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8];
|
||||
|
||||
val &= FLAG_MASK;
|
||||
*flags = val | (*flags & ~FLAG_MASK);
|
||||
break;
|
||||
@@ -128,7 +135,10 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
|
||||
if (regno > sizeof(struct user32) || (regno & 3))
|
||||
return -EIO;
|
||||
|
||||
/* Other dummy fields in the virtual user structure are ignored */
|
||||
/*
|
||||
* Other dummy fields in the virtual user structure
|
||||
* are ignored
|
||||
*/
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -137,7 +147,8 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
|
||||
#undef R32
|
||||
|
||||
#define R32(l,q) \
|
||||
case offsetof(struct user32, regs.l): *val = stack[offsetof(struct pt_regs, q)/8]; break
|
||||
case offsetof(struct user32, regs.l): \
|
||||
*val = stack[offsetof(struct pt_regs, q)/8]; break
|
||||
|
||||
static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
|
||||
{
|
||||
@@ -194,7 +205,10 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
|
||||
if (regno > sizeof(struct user32) || (regno & 3))
|
||||
return -EIO;
|
||||
|
||||
/* Other dummy fields in the virtual user structure are ignored */
|
||||
/*
|
||||
* Other dummy fields in the virtual user structure
|
||||
* are ignored
|
||||
*/
|
||||
*val = 0;
|
||||
break;
|
||||
}
|
||||
@@ -205,10 +219,11 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
|
||||
|
||||
static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
|
||||
{
|
||||
int ret;
|
||||
siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
|
||||
compat_siginfo_t __user *si32 = compat_ptr(data);
|
||||
siginfo_t ssi;
|
||||
siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
|
||||
int ret;
|
||||
|
||||
if (request == PTRACE_SETSIGINFO) {
|
||||
memset(&ssi, 0, sizeof(siginfo_t));
|
||||
ret = copy_siginfo_from_user32(&ssi, si32);
|
||||
@@ -287,7 +302,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
case PTRACE_PEEKDATA:
|
||||
case PTRACE_PEEKTEXT:
|
||||
ret = 0;
|
||||
if (access_process_vm(child, addr, &val, sizeof(u32), 0)!=sizeof(u32))
|
||||
if (access_process_vm(child, addr, &val, sizeof(u32), 0) !=
|
||||
sizeof(u32))
|
||||
ret = -EIO;
|
||||
else
|
||||
ret = put_user(val, (unsigned int __user *)datap);
|
||||
@@ -296,7 +312,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
case PTRACE_POKEDATA:
|
||||
case PTRACE_POKETEXT:
|
||||
ret = 0;
|
||||
if (access_process_vm(child, addr, &data, sizeof(u32), 1)!=sizeof(u32))
|
||||
if (access_process_vm(child, addr, &data, sizeof(u32), 1) !=
|
||||
sizeof(u32))
|
||||
ret = -EIO;
|
||||
break;
|
||||
|
||||
@@ -312,6 +329,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
|
||||
case PTRACE_GETREGS: { /* Get all gp regs from the child. */
|
||||
int i;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, datap, 16*4)) {
|
||||
ret = -EIO;
|
||||
break;
|
||||
@@ -328,6 +346,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
case PTRACE_SETREGS: { /* Set all gp regs in the child. */
|
||||
unsigned long tmp;
|
||||
int i;
|
||||
|
||||
if (!access_ok(VERIFY_READ, datap, 16*4)) {
|
||||
ret = -EIO;
|
||||
break;
|
||||
@@ -362,6 +381,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
|
||||
case PTRACE_GETFPXREGS: {
|
||||
struct user32_fxsr_struct __user *u = datap;
|
||||
|
||||
init_fpu(child);
|
||||
ret = -EIO;
|
||||
if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
|
||||
@@ -375,12 +395,15 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
}
|
||||
case PTRACE_SETFPXREGS: {
|
||||
struct user32_fxsr_struct __user *u = datap;
|
||||
|
||||
unlazy_fpu(child);
|
||||
ret = -EIO;
|
||||
if (!access_ok(VERIFY_READ, u, sizeof(*u)))
|
||||
break;
|
||||
/* no checking to be bug-to-bug compatible with i386. */
|
||||
/* but silence warning */
|
||||
/*
|
||||
* no checking to be bug-to-bug compatible with i386.
|
||||
* but silence warning
|
||||
*/
|
||||
if (__copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)))
|
||||
;
|
||||
set_stopped_child_used_math(child);
|
||||
@@ -390,7 +413,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
|
||||
}
|
||||
|
||||
case PTRACE_GETEVENTMSG:
|
||||
ret = put_user(child->ptrace_message,(unsigned int __user *)compat_ptr(data));
|
||||
ret = put_user(child->ptrace_message,
|
||||
(unsigned int __user *)compat_ptr(data));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user