Commit 345a8472 authored by Linus Torvalds's avatar Linus Torvalds

ppc64: more user address fixups.

Removed one (harmless) direct user pointer access.
parent 1581e330
...@@ -217,7 +217,7 @@ fix_alignment(struct pt_regs *regs) ...@@ -217,7 +217,7 @@ fix_alignment(struct pt_regs *regs)
unsigned dsisr; unsigned dsisr;
unsigned char __user *addr; unsigned char __user *addr;
unsigned char __user *p; unsigned char __user *p;
unsigned long *lp; unsigned long __user *lp;
union { union {
long ll; long ll;
double dd; double dd;
...@@ -242,9 +242,9 @@ fix_alignment(struct pt_regs *regs) ...@@ -242,9 +242,9 @@ fix_alignment(struct pt_regs *regs)
if (cur_cpu_spec->cpu_features & CPU_FTR_NODSISRALIGN) { if (cur_cpu_spec->cpu_features & CPU_FTR_NODSISRALIGN) {
unsigned int real_instr; unsigned int real_instr;
if (__get_user(real_instr, (unsigned int *)regs->nip)) if (__get_user(real_instr, (unsigned int __user *)regs->nip))
return 0; return 0;
dsisr = make_dsisr(*((unsigned *)regs->nip)); dsisr = make_dsisr(real_instr);
} }
/* extract the operation and registers from the dsisr */ /* extract the operation and registers from the dsisr */
...@@ -361,7 +361,7 @@ fix_alignment(struct pt_regs *regs) ...@@ -361,7 +361,7 @@ fix_alignment(struct pt_regs *regs)
p = addr; p = addr;
switch (nb) { switch (nb) {
case 128: /* Special case - must be dcbz */ case 128: /* Special case - must be dcbz */
lp = (unsigned long *)p; lp = (unsigned long __user *)p;
for (i = 0; i < L1_CACHE_BYTES / sizeof(long); ++i) for (i = 0; i < L1_CACHE_BYTES / sizeof(long); ++i)
ret |= __put_user(0, lp++); ret |= __put_user(0, lp++);
break; break;
......
...@@ -89,7 +89,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -89,7 +89,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
ret = -EIO; ret = -EIO;
if (copied != sizeof(tmp)) if (copied != sizeof(tmp))
break; break;
ret = put_user(tmp, (u32*)data); ret = put_user(tmp, (u32 __user *)data);
break; break;
} }
...@@ -106,19 +106,19 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -106,19 +106,19 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_PEEKDATA_3264: { case PPC_PTRACE_PEEKDATA_3264: {
u32 tmp; u32 tmp;
int copied; int copied;
u32* addrOthers; u32 __user * addrOthers;
ret = -EIO; ret = -EIO;
/* Get the addr in the other process that we want to read */ /* Get the addr in the other process that we want to read */
if (get_user(addrOthers, (u32**)addr) != 0) if (get_user(addrOthers, (u32 __user * __user *)addr) != 0)
break; break;
copied = access_process_vm(child, (u64)addrOthers, &tmp, copied = access_process_vm(child, (u64)addrOthers, &tmp,
sizeof(tmp), 0); sizeof(tmp), 0);
if (copied != sizeof(tmp)) if (copied != sizeof(tmp))
break; break;
ret = put_user(tmp, (u32*)data); ret = put_user(tmp, (u32 __user *)data);
break; break;
} }
...@@ -145,7 +145,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -145,7 +145,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
*/ */
tmp = ((unsigned int *)child->thread.fpr)[index - PT_FPR0]; tmp = ((unsigned int *)child->thread.fpr)[index - PT_FPR0];
} }
ret = put_user((unsigned int)tmp, (u32*)data); ret = put_user((unsigned int)tmp, (u32 __user *)data);
break; break;
} }
...@@ -186,7 +186,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -186,7 +186,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
tmp = get_reg(child, numReg); tmp = get_reg(child, numReg);
} }
reg32bits = ((u32*)&tmp)[part]; reg32bits = ((u32*)&tmp)[part];
ret = put_user(reg32bits, (u32*)data); ret = put_user(reg32bits, (u32 __user *)data);
break; break;
} }
...@@ -215,11 +215,11 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -215,11 +215,11 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_POKETEXT_3264: case PPC_PTRACE_POKETEXT_3264:
case PPC_PTRACE_POKEDATA_3264: { case PPC_PTRACE_POKEDATA_3264: {
u32 tmp = data; u32 tmp = data;
u32* addrOthers; u32 __user * addrOthers;
/* Get the addr in the other process that we want to write into */ /* Get the addr in the other process that we want to write into */
ret = -EIO; ret = -EIO;
if (get_user(addrOthers, (u32**)addr) != 0) if (get_user(addrOthers, (u32 __user * __user *)addr) != 0)
break; break;
ret = 0; ret = 0;
if (access_process_vm(child, (u64)addrOthers, &tmp, if (access_process_vm(child, (u64)addrOthers, &tmp,
...@@ -347,7 +347,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -347,7 +347,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */ case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */
int i; int i;
unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; unsigned long *reg = &((unsigned long *)child->thread.regs)[0];
unsigned int *tmp = (unsigned int *)addr; unsigned int __user *tmp = (unsigned int __user *)addr;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
ret = put_user(*reg, tmp); ret = put_user(*reg, tmp);
...@@ -362,7 +362,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -362,7 +362,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */ case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */
int i; int i;
unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; unsigned long *reg = &((unsigned long *)child->thread.regs)[0];
unsigned int *tmp = (unsigned int *)addr; unsigned int __user *tmp = (unsigned int __user *)addr;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
ret = get_user(*reg, tmp); ret = get_user(*reg, tmp);
...@@ -377,7 +377,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -377,7 +377,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_GETFPREGS: { /* Get FPRs 0 - 31. */ case PPC_PTRACE_GETFPREGS: { /* Get FPRs 0 - 31. */
int i; int i;
unsigned long *reg = &((unsigned long *)child->thread.fpr)[0]; unsigned long *reg = &((unsigned long *)child->thread.fpr)[0];
unsigned int *tmp = (unsigned int *)addr; unsigned int __user *tmp = (unsigned int __user *)addr;
if (child->thread.regs->msr & MSR_FP) if (child->thread.regs->msr & MSR_FP)
giveup_fpu(child); giveup_fpu(child);
...@@ -395,7 +395,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -395,7 +395,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PPC_PTRACE_SETFPREGS: { /* Get FPRs 0 - 31. */ case PPC_PTRACE_SETFPREGS: { /* Get FPRs 0 - 31. */
int i; int i;
unsigned long *reg = &((unsigned long *)child->thread.fpr)[0]; unsigned long *reg = &((unsigned long *)child->thread.fpr)[0];
unsigned int *tmp = (unsigned int *)addr; unsigned int __user *tmp = (unsigned int __user *)addr;
if (child->thread.regs->msr & MSR_FP) if (child->thread.regs->msr & MSR_FP)
giveup_fpu(child); giveup_fpu(child);
......
...@@ -165,7 +165,7 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext32 __user *frame, ...@@ -165,7 +165,7 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext32 __user *frame,
* significant bits of a vector, we "cheat" and stuff VRSAVE in the * significant bits of a vector, we "cheat" and stuff VRSAVE in the
* most significant bits of that same vector. --BenH * most significant bits of that same vector. --BenH
*/ */
if (__put_user(current->thread.vrsave, (u32 *)&frame->mc_vregs[32])) if (__put_user(current->thread.vrsave, (u32 __user *)&frame->mc_vregs[32]))
return 1; return 1;
#endif /* CONFIG_ALTIVEC */ #endif /* CONFIG_ALTIVEC */
...@@ -232,7 +232,7 @@ static long restore_user_regs(struct pt_regs *regs, ...@@ -232,7 +232,7 @@ static long restore_user_regs(struct pt_regs *regs,
memset(&current->thread.vr, 0, ELF_NVRREG32 * sizeof(vector128)); memset(&current->thread.vr, 0, ELF_NVRREG32 * sizeof(vector128));
/* Always get VRSAVE back */ /* Always get VRSAVE back */
if (__get_user(current->thread.vrsave, (u32 *)&sr->mc_vregs[32])) if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32]))
return 1; return 1;
#endif /* CONFIG_ALTIVEC */ #endif /* CONFIG_ALTIVEC */
...@@ -289,8 +289,8 @@ long sys32_sigsuspend(old_sigset_t mask, int p2, int p3, int p4, int p6, int p7, ...@@ -289,8 +289,8 @@ long sys32_sigsuspend(old_sigset_t mask, int p2, int p3, int p4, int p6, int p7,
} }
} }
long sys32_sigaction(int sig, struct old_sigaction32 *act, long sys32_sigaction(int sig, struct old_sigaction32 __user *act,
struct old_sigaction32 *oact) struct old_sigaction32 __user *oact)
{ {
struct k_sigaction new_ka, old_ka; struct k_sigaction new_ka, old_ka;
int ret; int ret;
...@@ -589,9 +589,11 @@ int sys32_rt_sigsuspend(compat_sigset_t __user * unewset, size_t sigsetsize, int ...@@ -589,9 +589,11 @@ int sys32_rt_sigsuspend(compat_sigset_t __user * unewset, size_t sigsetsize, int
* sigaltatck sys32_sigaltstack * sigaltatck sys32_sigaltstack
*/ */
int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5, int sys32_sigaltstack(u32 __new, u32 __old, int r5,
int r6, int r7, int r8, struct pt_regs *regs) int r6, int r7, int r8, struct pt_regs *regs)
{ {
stack_32_t __user * newstack = (stack_32_t __user *)(long) __new;
stack_32_t __user * oldstack = (stack_32_t __user *)(long) __old;
stack_t uss, uoss; stack_t uss, uoss;
int ret; int ret;
mm_segment_t old_fs; mm_segment_t old_fs;
...@@ -605,12 +607,9 @@ int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5, ...@@ -605,12 +607,9 @@ int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5,
/* Put new stack info in local 64 bit stack struct */ /* Put new stack info in local 64 bit stack struct */
if (newstack && if (newstack &&
(get_user((long)uss.ss_sp, (get_user((long)uss.ss_sp, &newstack->ss_sp) ||
&((stack_32_t *)(long)newstack)->ss_sp) || __get_user(uss.ss_flags, &newstack->ss_flags) ||
__get_user(uss.ss_flags, __get_user(uss.ss_size, &newstack->ss_size)))
&((stack_32_t *)(long)newstack)->ss_flags) ||
__get_user(uss.ss_size,
&((stack_32_t *)(long)newstack)->ss_size)))
return -EFAULT; return -EFAULT;
old_fs = get_fs(); old_fs = get_fs();
...@@ -623,12 +622,9 @@ int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5, ...@@ -623,12 +622,9 @@ int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5,
set_fs(old_fs); set_fs(old_fs);
/* Copy the stack information to the user output buffer */ /* Copy the stack information to the user output buffer */
if (!ret && oldstack && if (!ret && oldstack &&
(put_user((long)uoss.ss_sp, (put_user((long)uoss.ss_sp, &oldstack->ss_sp) ||
&((stack_32_t *)(long)oldstack)->ss_sp) || __put_user(uoss.ss_flags, &oldstack->ss_flags) ||
__put_user(uoss.ss_flags, __put_user(uoss.ss_size, &oldstack->ss_size)))
&((stack_32_t *)(long)oldstack)->ss_flags) ||
__put_user(uoss.ss_size,
&((stack_32_t *)(long)oldstack)->ss_size)))
return -EFAULT; return -EFAULT;
return ret; return ret;
} }
...@@ -746,8 +742,8 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx, ...@@ -746,8 +742,8 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx,
if (new_ctx == NULL) if (new_ctx == NULL)
return 0; return 0;
if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx)) if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx))
|| __get_user(tmp, (u8 *) new_ctx) || __get_user(tmp, (u8 __user *) new_ctx)
|| __get_user(tmp, (u8 *) (new_ctx + 1) - 1)) || __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1))
return -EFAULT; return -EFAULT;
/* /*
......
...@@ -173,7 +173,7 @@ static int filldir(void * __buf, const char * name, int namlen, off_t offset, ...@@ -173,7 +173,7 @@ static int filldir(void * __buf, const char * name, int namlen, off_t offset,
goto efault; goto efault;
if (__put_user(0, dirent->d_name + namlen)) if (__put_user(0, dirent->d_name + namlen))
goto efault; goto efault;
if (__put_user(d_type, (char *) dirent + reclen - 1)) if (__put_user(d_type, (char __user *) dirent + reclen - 1))
goto efault; goto efault;
buf->previous = dirent; buf->previous = dirent;
dirent = (void __user *)dirent + reclen; dirent = (void __user *)dirent + reclen;
...@@ -1105,7 +1105,7 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args) ...@@ -1105,7 +1105,7 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
int error; int error;
size_t oldlen; size_t oldlen;
size_t __user *oldlenp = NULL; size_t __user *oldlenp = NULL;
unsigned long addr = (((long)&args->__unused[0]) + 7) & ~7; unsigned long addr = (((unsigned long)&args->__unused[0]) + 7) & ~7;
if (copy_from_user(&tmp, args, sizeof(tmp))) if (copy_from_user(&tmp, args, sizeof(tmp)))
return -EFAULT; return -EFAULT;
...@@ -1118,7 +1118,7 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args) ...@@ -1118,7 +1118,7 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
glibc's __sysctl uses rw memory for the structure glibc's __sysctl uses rw memory for the structure
anyway. */ anyway. */
oldlenp = (size_t __user *)addr; oldlenp = (size_t __user *)addr;
if (get_user(oldlen, (u32 *)A(tmp.oldlenp)) || if (get_user(oldlen, (u32 __user *)A(tmp.oldlenp)) ||
put_user(oldlen, oldlenp)) put_user(oldlen, oldlenp))
return -EFAULT; return -EFAULT;
} }
......
...@@ -45,7 +45,7 @@ static int store_updates_sp(struct pt_regs *regs) ...@@ -45,7 +45,7 @@ static int store_updates_sp(struct pt_regs *regs)
{ {
unsigned int inst; unsigned int inst;
if (get_user(inst, (unsigned int *)regs->nip)) if (get_user(inst, (unsigned int __user *)regs->nip))
return 0; return 0;
/* check for 1 in the rA field */ /* check for 1 in the rA field */
if (((inst >> 16) & 0x1f) != 1) if (((inst >> 16) & 0x1f) != 1)
......
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