Commit e0f4d48c authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] verify_area cleanup : sparc and sparc64

This patch converts verify_area to access_ok for sparc and sparc64.
Signed-off-by: default avatarJesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 83ea1812
...@@ -374,8 +374,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -374,8 +374,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
struct pt_regs *cregs = child->thread.kregs; struct pt_regs *cregs = child->thread.kregs;
int rval; int rval;
rval = verify_area(VERIFY_WRITE, pregs, sizeof(struct pt_regs)); if (!access_ok(VERIFY_WRITE, pregs, sizeof(struct pt_regs))) {
if(rval) { rval = -EFAULT;
pt_error_return(regs, -rval); pt_error_return(regs, -rval);
goto out_tsk; goto out_tsk;
} }
...@@ -401,8 +401,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -401,8 +401,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
/* Must be careful, tracing process can only set certain /* Must be careful, tracing process can only set certain
* bits in the psr. * bits in the psr.
*/ */
i = verify_area(VERIFY_READ, pregs, sizeof(struct pt_regs)); if (!access_ok(VERIFY_READ, pregs, sizeof(struct pt_regs))) {
if(i) { i = -EFAULT;
pt_error_return(regs, -i); pt_error_return(regs, -i);
goto out_tsk; goto out_tsk;
} }
...@@ -439,8 +439,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -439,8 +439,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
struct fps __user *fps = (struct fps __user *) addr; struct fps __user *fps = (struct fps __user *) addr;
int i; int i;
i = verify_area(VERIFY_WRITE, fps, sizeof(struct fps)); if (!access_ok(VERIFY_WRITE, fps, sizeof(struct fps))) {
if(i) { i = -EFAULT;
pt_error_return(regs, -i); pt_error_return(regs, -i);
goto out_tsk; goto out_tsk;
} }
...@@ -474,8 +474,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -474,8 +474,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
struct fps __user *fps = (struct fps __user *) addr; struct fps __user *fps = (struct fps __user *) addr;
int i; int i;
i = verify_area(VERIFY_READ, fps, sizeof(struct fps)); if (!access_ok(VERIFY_READ, fps, sizeof(struct fps))) {
if(i) { i = -EFAULT;
pt_error_return(regs, -i); pt_error_return(regs, -i);
goto out_tsk; goto out_tsk;
} }
......
...@@ -205,7 +205,7 @@ restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) ...@@ -205,7 +205,7 @@ restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
set_used_math(); set_used_math();
clear_tsk_thread_flag(current, TIF_USEDFPU); clear_tsk_thread_flag(current, TIF_USEDFPU);
if (verify_area(VERIFY_READ, fpu, sizeof(*fpu))) if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
return -EFAULT; return -EFAULT;
err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0], err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
...@@ -231,7 +231,7 @@ static inline void do_new_sigreturn (struct pt_regs *regs) ...@@ -231,7 +231,7 @@ static inline void do_new_sigreturn (struct pt_regs *regs)
sf = (struct new_signal_frame __user *) regs->u_regs[UREG_FP]; sf = (struct new_signal_frame __user *) regs->u_regs[UREG_FP];
/* 1. Make sure we are not getting garbage from the user */ /* 1. Make sure we are not getting garbage from the user */
if (verify_area(VERIFY_READ, sf, sizeof(*sf))) if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
goto segv_and_exit; goto segv_and_exit;
if (((unsigned long) sf) & 3) if (((unsigned long) sf) & 3)
...@@ -297,7 +297,7 @@ asmlinkage void do_sigreturn(struct pt_regs *regs) ...@@ -297,7 +297,7 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
scptr = (struct sigcontext __user *) regs->u_regs[UREG_I0]; scptr = (struct sigcontext __user *) regs->u_regs[UREG_I0];
/* Check sanity of the user arg. */ /* Check sanity of the user arg. */
if (verify_area(VERIFY_READ, scptr, sizeof(struct sigcontext)) || if (!access_ok(VERIFY_READ, scptr, sizeof(struct sigcontext)) ||
(((unsigned long) scptr) & 3)) (((unsigned long) scptr) & 3))
goto segv_and_exit; goto segv_and_exit;
...@@ -356,7 +356,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) ...@@ -356,7 +356,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
synchronize_user_stack(); synchronize_user_stack();
sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP]; sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP];
if (verify_area(VERIFY_READ, sf, sizeof(*sf)) || if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
(((unsigned long) sf) & 0x03)) (((unsigned long) sf) & 0x03))
goto segv; goto segv;
......
...@@ -399,7 +399,7 @@ sparc_sigaction (int sig, const struct old_sigaction __user *act, ...@@ -399,7 +399,7 @@ sparc_sigaction (int sig, const struct old_sigaction __user *act,
if (act) { if (act) {
unsigned long mask; unsigned long mask;
if (verify_area(VERIFY_READ, act, sizeof(*act)) || if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) || __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -417,7 +417,7 @@ sparc_sigaction (int sig, const struct old_sigaction __user *act, ...@@ -417,7 +417,7 @@ sparc_sigaction (int sig, const struct old_sigaction __user *act,
* deadlock us if we held the signal lock on SMP. So for * deadlock us if we held the signal lock on SMP. So for
* now I take the easy way out and do no locking. * now I take the easy way out and do no locking.
*/ */
if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) || if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) || __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
return -EFAULT; return -EFAULT;
......
...@@ -1131,7 +1131,7 @@ sunos_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -1131,7 +1131,7 @@ sunos_sigaction(int sig, const struct old_sigaction __user *act,
if (act) { if (act) {
old_sigset_t mask; old_sigset_t mask;
if (verify_area(VERIFY_READ, act, sizeof(*act)) || if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) || __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags)) __get_user(new_ka.sa.sa_flags, &act->sa_flags))
return -EFAULT; return -EFAULT;
...@@ -1152,7 +1152,7 @@ sunos_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -1152,7 +1152,7 @@ sunos_sigaction(int sig, const struct old_sigaction __user *act,
* But then again we don't support SunOS lwp's anyways ;-) * But then again we don't support SunOS lwp's anyways ;-)
*/ */
old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT; old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT;
if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) || if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) || __put_user(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;
......
...@@ -428,40 +428,35 @@ static inline int ok_for_user(struct pt_regs *regs, unsigned int insn, ...@@ -428,40 +428,35 @@ static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
enum direction dir) enum direction dir)
{ {
unsigned int reg; unsigned int reg;
int retval, check = (dir == load) ? VERIFY_READ : VERIFY_WRITE; int check = (dir == load) ? VERIFY_READ : VERIFY_WRITE;
int size = ((insn >> 19) & 3) == 3 ? 8 : 4; int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
if ((regs->pc | regs->npc) & 3) if ((regs->pc | regs->npc) & 3)
return 0; return 0;
/* Must verify_area() in all the necessary places. */ /* Must access_ok() in all the necessary places. */
#define WINREG_ADDR(regnum) \ #define WINREG_ADDR(regnum) \
((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum))) ((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
retval = 0;
reg = (insn >> 25) & 0x1f; reg = (insn >> 25) & 0x1f;
if (reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), size); if (!access_ok(check, WINREG_ADDR(reg - 16), size))
if (retval) return -EFAULT;
return retval;
} }
reg = (insn >> 14) & 0x1f; reg = (insn >> 14) & 0x1f;
if (reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), size); if (!access_ok(check, WINREG_ADDR(reg - 16), size))
if (retval) return -EFAULT;
return retval;
} }
if (!(insn & 0x2000)) { if (!(insn & 0x2000)) {
reg = (insn & 0x1f); reg = (insn & 0x1f);
if (reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), if (!access_ok(check, WINREG_ADDR(reg - 16), size))
size); return -EFAULT;
if (retval)
return retval;
} }
} }
return retval;
#undef WINREG_ADDR #undef WINREG_ADDR
return 0;
} }
void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn) __asm__ ("user_mna_trap_fault"); void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn) __asm__ ("user_mna_trap_fault");
......
...@@ -114,9 +114,9 @@ static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file) ...@@ -114,9 +114,9 @@ static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file)
/* make sure we actually have a data and stack area to dump */ /* make sure we actually have a data and stack area to dump */
set_fs(USER_DS); set_fs(USER_DS);
if (verify_area(VERIFY_READ, (void __user *) START_DATA(dump), dump.u_dsize)) if (!access_ok(VERIFY_READ, (void __user *) START_DATA(dump), dump.u_dsize))
dump.u_dsize = 0; dump.u_dsize = 0;
if (verify_area(VERIFY_READ, (void __user *) START_STACK(dump), dump.u_ssize)) if (!access_ok(VERIFY_READ, (void __user *) START_STACK(dump), dump.u_ssize))
dump.u_ssize = 0; dump.u_ssize = 0;
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
......
...@@ -351,7 +351,7 @@ void do_new_sigreturn32(struct pt_regs *regs) ...@@ -351,7 +351,7 @@ void do_new_sigreturn32(struct pt_regs *regs)
sf = (struct new_signal_frame32 __user *) regs->u_regs[UREG_FP]; sf = (struct new_signal_frame32 __user *) regs->u_regs[UREG_FP];
/* 1. Make sure we are not getting garbage from the user */ /* 1. Make sure we are not getting garbage from the user */
if (verify_area(VERIFY_READ, sf, sizeof(*sf)) || if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
(((unsigned long) sf) & 3)) (((unsigned long) sf) & 3))
goto segv; goto segv;
...@@ -436,7 +436,7 @@ asmlinkage void do_sigreturn32(struct pt_regs *regs) ...@@ -436,7 +436,7 @@ asmlinkage void do_sigreturn32(struct pt_regs *regs)
scptr = (struct sigcontext32 __user *) scptr = (struct sigcontext32 __user *)
(regs->u_regs[UREG_I0] & 0x00000000ffffffffUL); (regs->u_regs[UREG_I0] & 0x00000000ffffffffUL);
/* Check sanity of the user arg. */ /* Check sanity of the user arg. */
if (verify_area(VERIFY_READ, scptr, sizeof(struct sigcontext32)) || if (!access_ok(VERIFY_READ, scptr, sizeof(struct sigcontext32)) ||
(((unsigned long) scptr) & 3)) (((unsigned long) scptr) & 3))
goto segv; goto segv;
...@@ -504,7 +504,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) ...@@ -504,7 +504,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
sf = (struct rt_signal_frame32 __user *) regs->u_regs[UREG_FP]; sf = (struct rt_signal_frame32 __user *) regs->u_regs[UREG_FP];
/* 1. Make sure we are not getting garbage from the user */ /* 1. Make sure we are not getting garbage from the user */
if (verify_area(VERIFY_READ, sf, sizeof(*sf)) || if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
(((unsigned long) sf) & 3)) (((unsigned long) sf) & 3))
goto segv; goto segv;
......
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