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