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

[PATCH] verify_area cleanup : x86_64 and ia64

This is the patch that converts verify_area to access_ok for the x86_64 
and ia64 archs.
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 e0f4d48c
......@@ -778,7 +778,7 @@ restore_sigcontext_ia32 (struct pt_regs *regs, struct sigcontext_ia32 __user *sc
struct _fpstate * buf;
err |= __get_user(buf, &sc->fpstate);
if (buf) {
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387(buf);
}
......@@ -978,7 +978,7 @@ sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
sigset_t set;
int eax;
if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
goto badframe;
if (__get_user(set.sig[0], &frame->sc.oldmask)
......@@ -1010,7 +1010,7 @@ sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4,
sigset_t set;
int eax;
if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
goto badframe;
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;
......
......@@ -2402,12 +2402,11 @@ sys32_epoll_ctl(int epfd, int op, int fd, struct epoll_event32 __user *event)
{
mm_segment_t old_fs = get_fs();
struct epoll_event event64;
int error = -EFAULT;
int error;
u32 data_halfword;
if ((error = verify_area(VERIFY_READ, event,
sizeof(struct epoll_event32))))
return error;
if (!access_ok(VERIFY_READ, event, sizeof(struct epoll_event32)))
return -EFAULT;
__get_user(event64.events, &event->events);
__get_user(data_halfword, &event->data[0]);
......@@ -2437,9 +2436,8 @@ sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents,
}
/* Verify that the area passed by the user is writeable */
if ((error = verify_area(VERIFY_WRITE, events,
maxevents * sizeof(struct epoll_event32))))
return error;
if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event32)))
return -EFAULT;
/*
* Allocate space for the intermediate copy. If the space needed
......
......@@ -1074,15 +1074,12 @@ ptrace_getregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
struct ia64_fpreg fpval;
struct switch_stack *sw;
struct pt_regs *pt;
long ret, retval;
long ret, retval = 0;
char nat = 0;
int i;
retval = verify_area(VERIFY_WRITE, ppr,
sizeof(struct pt_all_user_regs));
if (retval != 0) {
if (!access_ok(VERIFY_WRITE, ppr, sizeof(struct pt_all_user_regs)))
return -EIO;
}
pt = ia64_task_regs(child);
sw = (struct switch_stack *) (child->thread.ksp + 16);
......@@ -1105,8 +1102,6 @@ ptrace_getregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
|| access_uarea(child, PT_NAT_BITS, &nat_bits, 0))
return -EIO;
retval = 0;
/* control regs */
retval |= __put_user(pt->cr_iip, &ppr->cr_iip);
......@@ -1223,16 +1218,13 @@ ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
struct switch_stack *sw;
struct ia64_fpreg fpval;
struct pt_regs *pt;
long ret, retval;
long ret, retval = 0;
int i;
memset(&fpval, 0, sizeof(fpval));
retval = verify_area(VERIFY_READ, ppr,
sizeof(struct pt_all_user_regs));
if (retval != 0) {
if (!access_ok(VERIFY_READ, ppr, sizeof(struct pt_all_user_regs)))
return -EIO;
}
pt = ia64_task_regs(child);
sw = (struct switch_stack *) (child->thread.ksp + 16);
......@@ -1246,8 +1238,6 @@ ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
return -EIO;
}
retval = 0;
/* control regs */
retval |= __get_user(pt->cr_iip, &ppr->cr_iip);
......
......@@ -182,9 +182,9 @@ static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file)
/* make sure we actually have a data and stack area to dump */
set_fs(USER_DS);
if (verify_area(VERIFY_READ, (void *) (unsigned long)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
dump.u_dsize = 0;
if (verify_area(VERIFY_READ, (void *) (unsigned long)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
dump.u_ssize = 0;
set_fs(KERNEL_DS);
......
......@@ -256,7 +256,7 @@ ia32_restore_sigcontext(struct pt_regs *regs, struct sigcontext_ia32 __user *sc,
err |= __get_user(tmp, &sc->fpstate);
buf = compat_ptr(tmp);
if (buf) {
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387_ia32(current, buf, 0);
} else {
......@@ -285,7 +285,7 @@ asmlinkage long sys32_sigreturn(struct pt_regs *regs)
sigset_t set;
unsigned int eax;
if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
goto badframe;
if (__get_user(set.sig[0], &frame->sc.oldmask)
|| (_COMPAT_NSIG_WORDS > 1
......@@ -317,7 +317,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
frame = (struct rt_sigframe __user *)(regs->rsp - 4);
if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
goto badframe;
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;
......
......@@ -85,7 +85,7 @@ int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
return -EOVERFLOW;
if (kbuf->size >= 0x7fffffff)
return -EOVERFLOW;
if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
__put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
__put_user (kbuf->ino, &ubuf->st_ino) ||
__put_user (kbuf->mode, &ubuf->st_mode) ||
......@@ -128,7 +128,7 @@ cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
typeof(ubuf->st_gid) gid = 0;
SET_UID(uid, stat->uid);
SET_GID(gid, stat->gid);
if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
__put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
__put_user (stat->ino, &ubuf->__st_ino) ||
__put_user (stat->ino, &ubuf->st_ino) ||
......@@ -262,7 +262,7 @@ sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
if (act) {
compat_uptr_t handler, restorer;
if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(restorer, &act->sa_restorer)||
......@@ -301,7 +301,7 @@ sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
set32.sig[0] = old_ka.sa.sa_mask.sig[0];
}
if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
__put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
......@@ -322,7 +322,7 @@ sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigacti
compat_old_sigset_t mask;
compat_uptr_t handler, restorer;
if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(restorer, &act->sa_restorer) ||
......@@ -338,7 +338,7 @@ sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigacti
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
if (!ret && oact) {
if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
__put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
......@@ -567,7 +567,7 @@ sys32_sysinfo(struct sysinfo32 __user *info)
s.freehigh >>= bitcount;
}
if (verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
if (!access_ok(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
__put_user (s.uptime, &info->uptime) ||
__put_user (s.loads[0], &info->loads[0]) ||
__put_user (s.loads[1], &info->loads[1]) ||
......@@ -782,7 +782,7 @@ sys32_adjtimex(struct timex32 __user *utp)
memset(&txc, 0, sizeof(struct timex));
if(verify_area(VERIFY_READ, utp, sizeof(struct timex32)) ||
if (!access_ok(VERIFY_READ, utp, sizeof(struct timex32)) ||
__get_user(txc.modes, &utp->modes) ||
__get_user(txc.offset, &utp->offset) ||
__get_user(txc.freq, &utp->freq) ||
......@@ -807,7 +807,7 @@ sys32_adjtimex(struct timex32 __user *utp)
ret = do_adjtimex(&txc);
if(verify_area(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
if (!access_ok(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
__put_user(txc.modes, &utp->modes) ||
__put_user(txc.offset, &utp->offset) ||
__put_user(txc.freq, &utp->freq) ||
......
......@@ -121,7 +121,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, unsigned
err |= __get_user(buf, &sc->fpstate);
if (buf) {
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387(buf);
} else {
......@@ -147,7 +147,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
unsigned long eax;
frame = (struct rt_sigframe __user *)(regs->rsp - 8);
if (verify_area(VERIFY_READ, frame, sizeof(*frame))) {
if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) {
goto badframe;
}
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) {
......
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