Commit ffa56b35 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparc64 compat annotations

same story as for amd64 - ptr_to_compat() + normal __user annotations
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ae774bbf
...@@ -167,7 +167,7 @@ static void show_regwindow32(struct pt_regs *regs) ...@@ -167,7 +167,7 @@ static void show_regwindow32(struct pt_regs *regs)
mm_segment_t old_fs; mm_segment_t old_fs;
__asm__ __volatile__ ("flushw"); __asm__ __volatile__ ("flushw");
rw = (struct reg_window32 __user *)((long)(unsigned)regs->u_regs[14]); rw = compat_ptr((unsigned)regs->u_regs[14]);
old_fs = get_fs(); old_fs = get_fs();
set_fs (USER_DS); set_fs (USER_DS);
if (copy_from_user (&r_w, rw, sizeof(r_w))) { if (copy_from_user (&r_w, rw, sizeof(r_w))) {
......
...@@ -194,7 +194,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) ...@@ -194,7 +194,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
case __SI_FAULT >> 16: case __SI_FAULT >> 16:
case __SI_POLL >> 16: case __SI_POLL >> 16:
err |= __put_user(from->si_trapno, &to->si_trapno); err |= __put_user(from->si_trapno, &to->si_trapno);
err |= __put_user((long)from->si_addr, &to->si_addr); err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
break; break;
case __SI_RT >> 16: /* This is not generated by the kernel as of now. */ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
case __SI_MESGQ >> 16: case __SI_MESGQ >> 16:
...@@ -275,7 +275,7 @@ asmlinkage void do_rt_sigsuspend32(u32 uset, size_t sigsetsize, struct pt_regs * ...@@ -275,7 +275,7 @@ asmlinkage void do_rt_sigsuspend32(u32 uset, size_t sigsetsize, struct pt_regs *
regs->u_regs[UREG_I0] = EINVAL; regs->u_regs[UREG_I0] = EINVAL;
return; return;
} }
if (copy_from_user(&set32, (void __user *)(long)uset, sizeof(set32))) { if (copy_from_user(&set32, compat_ptr(uset), sizeof(set32))) {
regs->tstate |= TSTATE_ICARRY; regs->tstate |= TSTATE_ICARRY;
regs->u_regs[UREG_I0] = EFAULT; regs->u_regs[UREG_I0] = EFAULT;
return; return;
...@@ -720,9 +720,9 @@ setup_frame32(struct sigaction *sa, struct pt_regs *regs, int signr, sigset_t *o ...@@ -720,9 +720,9 @@ setup_frame32(struct sigaction *sa, struct pt_regs *regs, int signr, sigset_t *o
sig_address = NULL; sig_address = NULL;
} }
} }
err |= __put_user((long)sig_address, &sframep->sig_address); err |= __put_user(ptr_to_compat(sig_address), &sframep->sig_address);
err |= __put_user(sig_code, &sframep->sig_code); err |= __put_user(sig_code, &sframep->sig_code);
err |= __put_user((u64)sc, &sframep->sig_scptr); err |= __put_user(ptr_to_compat(sc), &sframep->sig_scptr);
if (err) if (err)
goto sigsegv; goto sigsegv;
...@@ -968,7 +968,7 @@ setup_svr4_frame32(struct sigaction *sa, unsigned long pc, unsigned long npc, ...@@ -968,7 +968,7 @@ setup_svr4_frame32(struct sigaction *sa, unsigned long pc, unsigned long npc,
/* Save the currently window file: */ /* Save the currently window file: */
/* 1. Link sfp->uc->gwins to our windows */ /* 1. Link sfp->uc->gwins to our windows */
err |= __put_user((u32)(long)gw, &mc->gwin); err |= __put_user(ptr_to_compat(gw), &mc->gwin);
/* 2. Number of windows to restore at setcontext (): */ /* 2. Number of windows to restore at setcontext (): */
err |= __put_user(get_thread_wsaved(), &gw->count); err |= __put_user(get_thread_wsaved(), &gw->count);
...@@ -1448,10 +1448,12 @@ asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp) ...@@ -1448,10 +1448,12 @@ asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp)
u32 u_ss_sp = 0; u32 u_ss_sp = 0;
int ret; int ret;
mm_segment_t old_fs; mm_segment_t old_fs;
stack_t32 __user *uss32 = compat_ptr(ussa);
stack_t32 __user *uoss32 = compat_ptr(uossa);
if (ussa && (get_user(u_ss_sp, &((stack_t32 __user *)(long)ussa)->ss_sp) || if (ussa && (get_user(u_ss_sp, &uss32->ss_sp) ||
__get_user(uss.ss_flags, &((stack_t32 __user *)(long)ussa)->ss_flags) || __get_user(uss.ss_flags, &uss32->ss_flags) ||
__get_user(uss.ss_size, &((stack_t32 __user *)(long)ussa)->ss_size))) __get_user(uss.ss_size, &uss32->ss_size)))
return -EFAULT; return -EFAULT;
uss.ss_sp = compat_ptr(u_ss_sp); uss.ss_sp = compat_ptr(u_ss_sp);
old_fs = get_fs(); old_fs = get_fs();
...@@ -1459,9 +1461,9 @@ asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp) ...@@ -1459,9 +1461,9 @@ asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp)
ret = do_sigaltstack(ussa ? (stack_t __user *) &uss : NULL, ret = do_sigaltstack(ussa ? (stack_t __user *) &uss : NULL,
uossa ? (stack_t __user *) &uoss : NULL, sp); uossa ? (stack_t __user *) &uoss : NULL, sp);
set_fs(old_fs); set_fs(old_fs);
if (!ret && uossa && (put_user((long)uoss.ss_sp, &((stack_t32 __user *)(long)uossa)->ss_sp) || if (!ret && uossa && (put_user(ptr_to_compat(uoss.ss_sp), &uoss32->ss_sp) ||
__put_user(uoss.ss_flags, &((stack_t32 __user *)(long)uossa)->ss_flags) || __put_user(uoss.ss_flags, &uoss32->ss_flags) ||
__put_user(uoss.ss_size, &((stack_t32 __user *)(long)uossa)->ss_size))) __put_user(uoss.ss_size, &uoss32->ss_size)))
return -EFAULT; return -EFAULT;
return ret; return ret;
} }
...@@ -86,7 +86,7 @@ extern int svr4_getcontext(svr4_ucontext_t *uc, struct pt_regs *regs); ...@@ -86,7 +86,7 @@ extern int svr4_getcontext(svr4_ucontext_t *uc, struct pt_regs *regs);
extern int svr4_setcontext(svr4_ucontext_t *uc, struct pt_regs *regs); extern int svr4_setcontext(svr4_ucontext_t *uc, struct pt_regs *regs);
extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *); extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
extern long sparc32_open(const char * filename, int flags, int mode); extern long sparc32_open(const char __user * filename, int flags, int mode);
extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space); extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space);
extern void (*prom_palette)(int); extern void (*prom_palette)(int);
......
...@@ -1090,8 +1090,8 @@ asmlinkage long compat_sys_sigaction(int sig, struct old_sigaction32 __user *act ...@@ -1090,8 +1090,8 @@ asmlinkage long compat_sys_sigaction(int sig, struct old_sigaction32 __user *act
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
if (!ret && oact) { if (!ret && oact) {
ret = put_user((long)old_ka.sa.sa_handler, &oact->sa_handler); ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler);
ret |= __put_user((long)old_ka.sa.sa_restorer, &oact->sa_restorer); ret |= __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer);
ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
ret |= __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); ret |= __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
} }
...@@ -1147,10 +1147,10 @@ asmlinkage long compat_sys_rt_sigaction(int sig, ...@@ -1147,10 +1147,10 @@ asmlinkage long compat_sys_rt_sigaction(int sig,
case 2: set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32); set32.sig[2] = old_ka.sa.sa_mask.sig[1]; case 2: set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32); set32.sig[2] = old_ka.sa.sa_mask.sig[1];
case 1: set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32); set32.sig[0] = old_ka.sa.sa_mask.sig[0]; case 1: set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32); set32.sig[0] = old_ka.sa.sa_mask.sig[0];
} }
ret = put_user((long)old_ka.sa.sa_handler, &oact->sa_handler); ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler);
ret |= __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t)); ret |= __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t));
ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
ret |= __put_user((long)old_ka.sa.sa_restorer, &oact->sa_restorer); ret |= __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer);
if (ret) if (ret)
ret = -EFAULT; ret = -EFAULT;
} }
......
...@@ -1177,11 +1177,11 @@ asmlinkage int sunos_shmsys(int op, u32 arg1, u32 arg2, u32 arg3) ...@@ -1177,11 +1177,11 @@ asmlinkage int sunos_shmsys(int op, u32 arg1, u32 arg2, u32 arg3)
return rval; return rval;
} }
extern asmlinkage long sparc32_open(const char * filename, int flags, int mode); extern asmlinkage long sparc32_open(const char __user * filename, int flags, int mode);
asmlinkage int sunos_open(u32 fname, int flags, int mode) asmlinkage int sunos_open(u32 fname, int flags, int mode)
{ {
const char *filename = (const char *)(long)fname; const char __user *filename = compat_ptr(fname);
return sparc32_open(filename, flags, mode); return sparc32_open(filename, flags, mode);
} }
...@@ -1294,7 +1294,7 @@ asmlinkage int sunos_sigaction (int sig, ...@@ -1294,7 +1294,7 @@ asmlinkage int sunos_sigaction (int sig,
if (!ret && oact) { if (!ret && oact) {
old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT; old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT;
if (put_user((long)old_ka.sa.sa_handler, &oact->sa_handler) || if (put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags)) __put_user(old_ka.sa.sa_flags, &oact->sa_flags))
return -EFAULT; return -EFAULT;
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
......
...@@ -121,6 +121,11 @@ static inline void __user *compat_ptr(compat_uptr_t uptr) ...@@ -121,6 +121,11 @@ static inline void __user *compat_ptr(compat_uptr_t uptr)
return (void __user *)(unsigned long)uptr; return (void __user *)(unsigned long)uptr;
} }
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
{
return (u32)(unsigned long)uptr;
}
static __inline__ void __user *compat_alloc_user_space(long len) static __inline__ void __user *compat_alloc_user_space(long len)
{ {
struct pt_regs *regs = current_thread_info()->kregs; struct pt_regs *regs = current_thread_info()->kregs;
......
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