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

[PATCH] verify_area cleanup: mips

This is the patch to convert verify_area to access_ok for arch/mips
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 4b8e0729
...@@ -887,12 +887,11 @@ unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt) ...@@ -887,12 +887,11 @@ unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt)
/* First get the verification out of the way. */ /* First get the verification out of the way. */
hp = user_phdrp; hp = user_phdrp;
retval = verify_area(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt)); if (!access_ok(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt))) {
if(retval) {
#ifdef DEBUG_ELF #ifdef DEBUG_ELF
printk("irix_mapelf: verify_area fails!\n"); printk("irix_mapelf: access_ok fails!\n");
#endif #endif
return retval; return -EFAULT;
} }
#ifdef DEBUG_ELF #ifdef DEBUG_ELF
......
...@@ -36,8 +36,8 @@ int dump_inventory_to_user (void *userbuf, int size) ...@@ -36,8 +36,8 @@ int dump_inventory_to_user (void *userbuf, int size)
inventory_t *user = userbuf; inventory_t *user = userbuf;
int v; int v;
if ((v = verify_area (VERIFY_WRITE, userbuf, size))) if (!access_ok(VERIFY_WRITE, userbuf, size))
return v; return -EFAULT;
for (v = 0; v < inventory_items; v++){ for (v = 0; v < inventory_items; v++){
inv = &inventory [v]; inv = &inventory [v];
......
...@@ -312,7 +312,7 @@ irix_sigaction(int sig, const struct sigaction *act, ...@@ -312,7 +312,7 @@ irix_sigaction(int sig, const struct sigaction *act,
#endif #endif
if (act) { if (act) {
sigset_t mask; 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;
...@@ -331,7 +331,7 @@ irix_sigaction(int sig, const struct sigaction *act, ...@@ -331,7 +331,7 @@ irix_sigaction(int sig, const struct sigaction *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) {
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;
...@@ -350,12 +350,10 @@ asmlinkage int irix_sigpending(irix_sigset_t *set) ...@@ -350,12 +350,10 @@ asmlinkage int irix_sigpending(irix_sigset_t *set)
asmlinkage int irix_sigprocmask(int how, irix_sigset_t *new, irix_sigset_t *old) asmlinkage int irix_sigprocmask(int how, irix_sigset_t *new, irix_sigset_t *old)
{ {
sigset_t oldbits, newbits; sigset_t oldbits, newbits;
int error;
if (new) { if (new) {
error = verify_area(VERIFY_READ, new, sizeof(*new)); if (!access_ok(VERIFY_READ, new, sizeof(*new)))
if (error) return -EFAULT;
return error;
__copy_from_user(&newbits, new, sizeof(unsigned long)*4); __copy_from_user(&newbits, new, sizeof(unsigned long)*4);
sigdelsetmask(&newbits, ~_BLOCKABLE); sigdelsetmask(&newbits, ~_BLOCKABLE);
...@@ -385,9 +383,8 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t *new, irix_sigset_t *old) ...@@ -385,9 +383,8 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t *new, irix_sigset_t *old)
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
} }
if(old) { if(old) {
error = verify_area(VERIFY_WRITE, old, sizeof(*old)); if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
if(error) return -EFAULT;
return error;
__copy_to_user(old, &current->blocked, sizeof(unsigned long)*4); __copy_to_user(old, &current->blocked, sizeof(unsigned long)*4);
} }
...@@ -469,12 +466,13 @@ asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info, ...@@ -469,12 +466,13 @@ asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
#endif #endif
/* Must always specify the signal set. */ /* Must always specify the signal set. */
if(!set) if (!set)
return -EINVAL; return -EINVAL;
error = verify_area(VERIFY_READ, set, sizeof(kset)); if (!access_ok(VERIFY_READ, set, sizeof(kset))) {
if (error) error = -EFAULT;
goto out; goto out;
}
__copy_from_user(&kset, set, sizeof(set)); __copy_from_user(&kset, set, sizeof(set));
if (error) if (error)
...@@ -485,11 +483,10 @@ asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info, ...@@ -485,11 +483,10 @@ asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
goto out; goto out;
} }
if(tp) { if (tp) {
error = verify_area(VERIFY_READ, tp, sizeof(*tp)); if (!access_ok(VERIFY_READ, tp, sizeof(*tp)))
if(error) return -EFAULT;
return error; if (!tp->tv_sec && !tp->tv_nsec) {
if(!tp->tv_sec && !tp->tv_nsec) {
error = -EINVAL; error = -EINVAL;
goto out; goto out;
} }
...@@ -564,13 +561,15 @@ asmlinkage int irix_waitsys(int type, int pid, struct irix5_siginfo *info, ...@@ -564,13 +561,15 @@ asmlinkage int irix_waitsys(int type, int pid, struct irix5_siginfo *info,
retval = -EINVAL; retval = -EINVAL;
goto out; goto out;
} }
retval = verify_area(VERIFY_WRITE, info, sizeof(*info)); if (!access_ok(VERIFY_WRITE, info, sizeof(*info))) {
if(retval) retval = -EFAULT;
goto out; goto out;
}
if (ru) { if (ru) {
retval = verify_area(VERIFY_WRITE, ru, sizeof(*ru)); if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru))) {
if(retval) retval = -EFAULT;
goto out; goto out;
}
} }
if (options & ~(W_MASK)) { if (options & ~(W_MASK)) {
retval = -EINVAL; retval = -EINVAL;
...@@ -690,7 +689,7 @@ struct irix5_context { ...@@ -690,7 +689,7 @@ struct irix5_context {
asmlinkage int irix_getcontext(struct pt_regs *regs) asmlinkage int irix_getcontext(struct pt_regs *regs)
{ {
int error, i, base = 0; int i, base = 0;
struct irix5_context *ctx; struct irix5_context *ctx;
unsigned long flags; unsigned long flags;
...@@ -703,9 +702,9 @@ asmlinkage int irix_getcontext(struct pt_regs *regs) ...@@ -703,9 +702,9 @@ asmlinkage int irix_getcontext(struct pt_regs *regs)
current->comm, current->pid, ctx); current->comm, current->pid, ctx);
#endif #endif
error = verify_area(VERIFY_WRITE, ctx, sizeof(*ctx)); if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
if(error) return -EFAULT;
goto out;
__put_user(current->thread.irix_oldctx, &ctx->link); __put_user(current->thread.irix_oldctx, &ctx->link);
__copy_to_user(&ctx->sigmask, &current->blocked, sizeof(irix_sigset_t)); __copy_to_user(&ctx->sigmask, &current->blocked, sizeof(irix_sigset_t));
...@@ -725,17 +724,15 @@ asmlinkage int irix_getcontext(struct pt_regs *regs) ...@@ -725,17 +724,15 @@ asmlinkage int irix_getcontext(struct pt_regs *regs)
__put_user(regs->cp0_epc, &ctx->regs[35]); __put_user(regs->cp0_epc, &ctx->regs[35]);
flags = 0x0f; flags = 0x0f;
if(!used_math()) { if (!used_math()) {
flags &= ~(0x08); flags &= ~(0x08);
} else { } else {
/* XXX wheee... */ /* XXX wheee... */
printk("Wheee, no code for saving IRIX FPU context yet.\n"); printk("Wheee, no code for saving IRIX FPU context yet.\n");
} }
__put_user(flags, &ctx->flags); __put_user(flags, &ctx->flags);
error = 0;
out: return 0;
return error;
} }
asmlinkage unsigned long irix_setcontext(struct pt_regs *regs) asmlinkage unsigned long irix_setcontext(struct pt_regs *regs)
...@@ -752,9 +749,10 @@ asmlinkage unsigned long irix_setcontext(struct pt_regs *regs) ...@@ -752,9 +749,10 @@ asmlinkage unsigned long irix_setcontext(struct pt_regs *regs)
current->comm, current->pid, ctx); current->comm, current->pid, ctx);
#endif #endif
error = verify_area(VERIFY_READ, ctx, sizeof(*ctx)); if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx))) {
if (error) error = -EFAULT;
goto out; goto out;
}
if (ctx->flags & 0x02) { if (ctx->flags & 0x02) {
/* XXX sigstack garbage, todo... */ /* XXX sigstack garbage, todo... */
...@@ -787,21 +785,19 @@ struct irix_sigstack { unsigned long sp; int status; }; ...@@ -787,21 +785,19 @@ struct irix_sigstack { unsigned long sp; int status; };
asmlinkage int irix_sigstack(struct irix_sigstack *new, struct irix_sigstack *old) asmlinkage int irix_sigstack(struct irix_sigstack *new, struct irix_sigstack *old)
{ {
int error; int error = -EFAULT;
#ifdef DEBUG_SIG #ifdef DEBUG_SIG
printk("[%s:%d] irix_sigstack(%p,%p)\n", printk("[%s:%d] irix_sigstack(%p,%p)\n",
current->comm, current->pid, new, old); current->comm, current->pid, new, old);
#endif #endif
if(new) { if(new) {
error = verify_area(VERIFY_READ, new, sizeof(*new)); if (!access_ok(VERIFY_READ, new, sizeof(*new)))
if(error)
goto out; goto out;
} }
if(old) { if(old) {
error = verify_area(VERIFY_WRITE, old, sizeof(*old)); if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
if(error)
goto out; goto out;
} }
error = 0; error = 0;
...@@ -815,21 +811,19 @@ struct irix_sigaltstack { unsigned long sp; int size; int status; }; ...@@ -815,21 +811,19 @@ struct irix_sigaltstack { unsigned long sp; int size; int status; };
asmlinkage int irix_sigaltstack(struct irix_sigaltstack *new, asmlinkage int irix_sigaltstack(struct irix_sigaltstack *new,
struct irix_sigaltstack *old) struct irix_sigaltstack *old)
{ {
int error; int error = -EFAULT;
#ifdef DEBUG_SIG #ifdef DEBUG_SIG
printk("[%s:%d] irix_sigaltstack(%p,%p)\n", printk("[%s:%d] irix_sigaltstack(%p,%p)\n",
current->comm, current->pid, new, old); current->comm, current->pid, new, old);
#endif #endif
if (new) { if (new) {
error = verify_area(VERIFY_READ, new, sizeof(*new)); if (!access_ok(VERIFY_READ, new, sizeof(*new)))
if(error)
goto out; goto out;
} }
if (old) { if (old) {
error = verify_area(VERIFY_WRITE, old, sizeof(*old)); if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
if(error)
goto out; goto out;
} }
error = 0; error = 0;
...@@ -848,9 +842,10 @@ asmlinkage int irix_sigsendset(struct irix_procset *pset, int sig) ...@@ -848,9 +842,10 @@ asmlinkage int irix_sigsendset(struct irix_procset *pset, int sig)
{ {
int error; int error;
error = verify_area(VERIFY_READ, pset, sizeof(*pset)); if (!access_ok(VERIFY_READ, pset, sizeof(*pset))) {
if(error) error = -EFAULT;
goto out; goto out;
}
#ifdef DEBUG_SIG #ifdef DEBUG_SIG
printk("[%s:%d] irix_sigsendset([%d,%d,%d,%d,%d],%d)\n", printk("[%s:%d] irix_sigsendset([%d,%d,%d,%d,%d],%d)\n",
current->comm, current->pid, current->comm, current->pid,
......
...@@ -239,7 +239,7 @@ put_rusage (struct rusage32 *ru, struct rusage *r) ...@@ -239,7 +239,7 @@ put_rusage (struct rusage32 *ru, struct rusage *r)
{ {
int err; int err;
if (verify_area(VERIFY_WRITE, ru, sizeof *ru)) if (!access_ok(VERIFY_WRITE, ru, sizeof *ru))
return -EFAULT; return -EFAULT;
err = __put_user (r->ru_utime.tv_sec, &ru->ru_utime.tv_sec); err = __put_user (r->ru_utime.tv_sec, &ru->ru_utime.tv_sec);
......
...@@ -289,9 +289,10 @@ asmlinkage int irix_syssgi(struct pt_regs *regs) ...@@ -289,9 +289,10 @@ asmlinkage int irix_syssgi(struct pt_regs *regs)
struct task_struct *p; struct task_struct *p;
char tcomm[sizeof(current->comm)]; char tcomm[sizeof(current->comm)];
retval = verify_area(VERIFY_WRITE, buf, sizeof(tcomm)); if (!access_ok(VERIFY_WRITE, buf, sizeof(tcomm))) {
if (retval) retval = -EFAULT;
break; break;
}
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
p = find_task_by_pid(pid); p = find_task_by_pid(pid);
if (!p) { if (!p) {
...@@ -313,9 +314,10 @@ asmlinkage int irix_syssgi(struct pt_regs *regs) ...@@ -313,9 +314,10 @@ asmlinkage int irix_syssgi(struct pt_regs *regs)
char *buf = (char *) regs->regs[base+6]; char *buf = (char *) regs->regs[base+6];
char *value; char *value;
return -EINVAL; /* til I fix it */ return -EINVAL; /* til I fix it */
retval = verify_area(VERIFY_WRITE, buf, 128); if (!access_ok(VERIFY_WRITE, buf, 128)) {
if (retval) retval = -EFAULT;
break; break;
}
value = prom_getenv(name); /* PROM lock? */ value = prom_getenv(name); /* PROM lock? */
if (!value) { if (!value) {
retval = -EINVAL; retval = -EINVAL;
...@@ -472,9 +474,8 @@ asmlinkage int irix_syssgi(struct pt_regs *regs) ...@@ -472,9 +474,8 @@ asmlinkage int irix_syssgi(struct pt_regs *regs)
pmd_t *pmdp; pmd_t *pmdp;
pte_t *ptep; pte_t *ptep;
retval = verify_area(VERIFY_WRITE, pageno, sizeof(int)); if (!access_ok(VERIFY_WRITE, pageno, sizeof(int)))
if (retval) return -EFAULT;
return retval;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
pgdp = pgd_offset(mm, addr); pgdp = pgd_offset(mm, addr);
...@@ -727,9 +728,10 @@ asmlinkage int irix_statfs(const char *path, struct irix_statfs *buf, ...@@ -727,9 +728,10 @@ asmlinkage int irix_statfs(const char *path, struct irix_statfs *buf,
error = -EINVAL; error = -EINVAL;
goto out; goto out;
} }
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
if (error) error = -EFAULT;
goto out; goto out;
}
error = user_path_walk(path, &nd); error = user_path_walk(path, &nd);
if (error) if (error)
goto out; goto out;
...@@ -763,9 +765,10 @@ asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf) ...@@ -763,9 +765,10 @@ asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf)
struct file *file; struct file *file;
int error, i; int error, i;
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
if (error) error = -EFAULT;
goto out; goto out;
}
if (!(file = fget(fd))) { if (!(file = fget(fd))) {
error = -EBADF; error = -EBADF;
goto out; goto out;
...@@ -816,9 +819,8 @@ asmlinkage int irix_times(struct tms * tbuf) ...@@ -816,9 +819,8 @@ asmlinkage int irix_times(struct tms * tbuf)
int err = 0; int err = 0;
if (tbuf) { if (tbuf) {
err = verify_area(VERIFY_WRITE,tbuf,sizeof *tbuf); if (!access_ok(VERIFY_WRITE,tbuf,sizeof *tbuf))
if (err) return -EFAULT;
return err;
err |= __put_user(current->utime, &tbuf->tms_utime); err |= __put_user(current->utime, &tbuf->tms_utime);
err |= __put_user(current->stime, &tbuf->tms_stime); err |= __put_user(current->stime, &tbuf->tms_stime);
err |= __put_user(current->signal->cutime, &tbuf->tms_cutime); err |= __put_user(current->signal->cutime, &tbuf->tms_cutime);
...@@ -919,9 +921,8 @@ asmlinkage int irix_getdomainname(char *name, int len) ...@@ -919,9 +921,8 @@ asmlinkage int irix_getdomainname(char *name, int len)
{ {
int error; int error;
error = verify_area(VERIFY_WRITE, name, len); if (!access_ok(VERIFY_WRITE, name, len))
if (error) return -EFAULT;
return error;
down_read(&uts_sem); down_read(&uts_sem);
if (len > __NEW_UTS_LEN) if (len > __NEW_UTS_LEN)
...@@ -1050,7 +1051,7 @@ asmlinkage int irix_gettimeofday(struct timeval *tv) ...@@ -1050,7 +1051,7 @@ asmlinkage int irix_gettimeofday(struct timeval *tv)
long nsec, seq; long nsec, seq;
int err; int err;
if (verify_area(VERIFY_WRITE, tv, sizeof(struct timeval))) if (!access_ok(VERIFY_WRITE, tv, sizeof(struct timeval)))
return -EFAULT; return -EFAULT;
do { do {
...@@ -1396,9 +1397,10 @@ asmlinkage int irix_statvfs(char *fname, struct irix_statvfs *buf) ...@@ -1396,9 +1397,10 @@ asmlinkage int irix_statvfs(char *fname, struct irix_statvfs *buf)
printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n", printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
current->comm, current->pid, fname, buf); current->comm, current->pid, fname, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
if (error) error = -EFAULT;
goto out; goto out;
}
error = user_path_walk(fname, &nd); error = user_path_walk(fname, &nd);
if (error) if (error)
goto out; goto out;
...@@ -1443,9 +1445,10 @@ asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf) ...@@ -1443,9 +1445,10 @@ asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf)
printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n", printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
current->comm, current->pid, fd, buf); current->comm, current->pid, fd, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
if (error) error = -EFAULT;
goto out; goto out;
}
if (!(file = fget(fd))) { if (!(file = fget(fd))) {
error = -EBADF; error = -EBADF;
goto out; goto out;
...@@ -1537,16 +1540,18 @@ asmlinkage int irix_mmap64(struct pt_regs *regs) ...@@ -1537,16 +1540,18 @@ asmlinkage int irix_mmap64(struct pt_regs *regs)
prot = regs->regs[base + 6]; prot = regs->regs[base + 6];
if (!base) { if (!base) {
flags = regs->regs[base + 7]; flags = regs->regs[base + 7];
error = verify_area(VERIFY_READ, sp, (4 * sizeof(unsigned long))); if (!access_ok(VERIFY_READ, sp, (4 * sizeof(unsigned long)))) {
if(error) error = -EFAULT;
goto out; goto out;
}
fd = sp[0]; fd = sp[0];
__get_user(off1, &sp[1]); __get_user(off1, &sp[1]);
__get_user(off2, &sp[2]); __get_user(off2, &sp[2]);
} else { } else {
error = verify_area(VERIFY_READ, sp, (5 * sizeof(unsigned long))); if (!access_ok(VERIFY_READ, sp, (5 * sizeof(unsigned long)))) {
if(error) error = -EFAULT;
goto out; goto out;
}
__get_user(flags, &sp[0]); __get_user(flags, &sp[0]);
__get_user(fd, &sp[1]); __get_user(fd, &sp[1]);
__get_user(off1, &sp[2]); __get_user(off1, &sp[2]);
...@@ -1650,9 +1655,10 @@ asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf) ...@@ -1650,9 +1655,10 @@ asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf)
printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n", printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
current->comm, current->pid, fname, buf); current->comm, current->pid, fname, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64))) {
if(error) error = -EFAULT;
goto out; goto out;
}
error = user_path_walk(fname, &nd); error = user_path_walk(fname, &nd);
if (error) if (error)
goto out; goto out;
...@@ -1697,9 +1703,10 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf) ...@@ -1697,9 +1703,10 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n", printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
current->comm, current->pid, fd, buf); current->comm, current->pid, fd, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)); if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
if (error) error = -EFAULT;
goto out; goto out;
}
if (!(file = fget(fd))) { if (!(file = fget(fd))) {
error = -EBADF; error = -EBADF;
goto out; goto out;
...@@ -1735,13 +1742,12 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf) ...@@ -1735,13 +1742,12 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
asmlinkage int irix_getmountid(char *fname, unsigned long *midbuf) asmlinkage int irix_getmountid(char *fname, unsigned long *midbuf)
{ {
int err; int err = 0;
printk("[%s:%d] irix_getmountid(%s, %p)\n", printk("[%s:%d] irix_getmountid(%s, %p)\n",
current->comm, current->pid, fname, midbuf); current->comm, current->pid, fname, midbuf);
err = verify_area(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4)); if (!access_ok(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4)))
if (err) return -EFAULT;
return err;
/* /*
* The idea with this system call is that when trying to determine * The idea with this system call is that when trying to determine
......
...@@ -143,7 +143,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -143,7 +143,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
* The remaining opcodes are the ones that are really of interest. * The remaining opcodes are the ones that are really of interest.
*/ */
case lh_op: case lh_op:
if (verify_area(VERIFY_READ, addr, 2)) if (!access_ok(VERIFY_READ, addr, 2))
goto sigbus; goto sigbus;
__asm__ __volatile__ (".set\tnoat\n" __asm__ __volatile__ (".set\tnoat\n"
...@@ -176,7 +176,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -176,7 +176,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
break; break;
case lw_op: case lw_op:
if (verify_area(VERIFY_READ, addr, 4)) if (!access_ok(VERIFY_READ, addr, 4))
goto sigbus; goto sigbus;
__asm__ __volatile__ ( __asm__ __volatile__ (
...@@ -206,7 +206,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -206,7 +206,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
break; break;
case lhu_op: case lhu_op:
if (verify_area(VERIFY_READ, addr, 2)) if (!access_ok(VERIFY_READ, addr, 2))
goto sigbus; goto sigbus;
__asm__ __volatile__ ( __asm__ __volatile__ (
...@@ -248,7 +248,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -248,7 +248,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
* would blow up, so for now we don't handle unaligned 64-bit * would blow up, so for now we don't handle unaligned 64-bit
* instructions on 32-bit kernels. * instructions on 32-bit kernels.
*/ */
if (verify_area(VERIFY_READ, addr, 4)) if (!access_ok(VERIFY_READ, addr, 4))
goto sigbus; goto sigbus;
__asm__ __volatile__ ( __asm__ __volatile__ (
...@@ -292,7 +292,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -292,7 +292,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
* would blow up, so for now we don't handle unaligned 64-bit * would blow up, so for now we don't handle unaligned 64-bit
* instructions on 32-bit kernels. * instructions on 32-bit kernels.
*/ */
if (verify_area(VERIFY_READ, addr, 8)) if (!access_ok(VERIFY_READ, addr, 8))
goto sigbus; goto sigbus;
__asm__ __volatile__ ( __asm__ __volatile__ (
...@@ -326,7 +326,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -326,7 +326,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
goto sigill; goto sigill;
case sh_op: case sh_op:
if (verify_area(VERIFY_WRITE, addr, 2)) if (!access_ok(VERIFY_WRITE, addr, 2))
goto sigbus; goto sigbus;
value = regs->regs[insn.i_format.rt]; value = regs->regs[insn.i_format.rt];
...@@ -362,7 +362,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -362,7 +362,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
break; break;
case sw_op: case sw_op:
if (verify_area(VERIFY_WRITE, addr, 4)) if (!access_ok(VERIFY_WRITE, addr, 4))
goto sigbus; goto sigbus;
value = regs->regs[insn.i_format.rt]; value = regs->regs[insn.i_format.rt];
...@@ -400,7 +400,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs, ...@@ -400,7 +400,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
* would blow up, so for now we don't handle unaligned 64-bit * would blow up, so for now we don't handle unaligned 64-bit
* instructions on 32-bit kernels. * instructions on 32-bit kernels.
*/ */
if (verify_area(VERIFY_WRITE, addr, 8)) if (!access_ok(VERIFY_WRITE, addr, 8))
goto sigbus; goto sigbus;
value = regs->regs[insn.i_format.rt]; value = regs->regs[insn.i_format.rt];
......
...@@ -95,7 +95,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, gpreg_t cpc) ...@@ -95,7 +95,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, gpreg_t cpc)
fr = (struct emuframe *) dsemul_insns; fr = (struct emuframe *) dsemul_insns;
/* Verify that the stack pointer is not competely insane */ /* Verify that the stack pointer is not competely insane */
if (unlikely(verify_area(VERIFY_WRITE, fr, sizeof(struct emuframe)))) if (unlikely(!access_ok(VERIFY_WRITE, fr, sizeof(struct emuframe))))
return SIGBUS; return SIGBUS;
err = __put_user(ir, &fr->emul); err = __put_user(ir, &fr->emul);
...@@ -128,7 +128,7 @@ int do_dsemulret(struct pt_regs *xcp) ...@@ -128,7 +128,7 @@ int do_dsemulret(struct pt_regs *xcp)
* If we can't even access the area, something is very wrong, but we'll * If we can't even access the area, something is very wrong, but we'll
* leave that to the default handling * leave that to the default handling
*/ */
if (verify_area(VERIFY_READ, fr, sizeof(struct emuframe))) if (!access_ok(VERIFY_READ, fr, sizeof(struct emuframe)))
return 0; return 0;
/* /*
...@@ -142,7 +142,6 @@ int do_dsemulret(struct pt_regs *xcp) ...@@ -142,7 +142,6 @@ int do_dsemulret(struct pt_regs *xcp)
if (unlikely(err || (insn != BADINST) || (cookie != BD_COOKIE))) { if (unlikely(err || (insn != BADINST) || (cookie != BD_COOKIE))) {
fpuemuprivate.stats.errors++; fpuemuprivate.stats.errors++;
return 0; return 0;
} }
......
...@@ -52,7 +52,7 @@ EXPORT_SYMBOL(_dma_cache_inv); ...@@ -52,7 +52,7 @@ EXPORT_SYMBOL(_dma_cache_inv);
asmlinkage int sys_cacheflush(unsigned long addr, unsigned long int bytes, asmlinkage int sys_cacheflush(unsigned long addr, unsigned long int bytes,
unsigned int cache) unsigned int cache)
{ {
if (verify_area(VERIFY_WRITE, (void *) addr, bytes)) if (!access_ok(VERIFY_WRITE, (void *) addr, bytes))
return -EFAULT; return -EFAULT;
flush_icache_range(addr, addr + bytes); flush_icache_range(addr, addr + bytes);
......
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