Commit 83ea1812 authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] verify_area cleanup : ppc, ppc64, m68k, m68knommu

Convert verify_area to access_ok for ppc, ppc64, m68k and m68knommu
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 ae090d92
...@@ -130,7 +130,7 @@ sys_sigaction(int sig, const struct old_sigaction *act, ...@@ -130,7 +130,7 @@ sys_sigaction(int sig, const struct old_sigaction *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_restorer, &act->sa_restorer)) __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -142,7 +142,7 @@ sys_sigaction(int sig, const struct old_sigaction *act, ...@@ -142,7 +142,7 @@ sys_sigaction(int sig, const struct old_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_restorer, &oact->sa_restorer)) __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -510,7 +510,7 @@ asmlinkage int do_sigreturn(unsigned long __unused) ...@@ -510,7 +510,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
sigset_t set; sigset_t set;
int d0; int d0;
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.sc_mask) || if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
(_NSIG_WORDS > 1 && (_NSIG_WORDS > 1 &&
...@@ -540,7 +540,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused) ...@@ -540,7 +540,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
sigset_t set; sigset_t set;
int d0; int d0;
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;
......
...@@ -116,7 +116,7 @@ sys_sigaction(int sig, const struct old_sigaction *act, ...@@ -116,7 +116,7 @@ sys_sigaction(int sig, const struct old_sigaction *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_restorer, &act->sa_restorer)) __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -128,7 +128,7 @@ sys_sigaction(int sig, const struct old_sigaction *act, ...@@ -128,7 +128,7 @@ sys_sigaction(int sig, const struct old_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_restorer, &oact->sa_restorer)) __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -360,7 +360,7 @@ asmlinkage int do_sigreturn(unsigned long __unused) ...@@ -360,7 +360,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
sigset_t set; sigset_t set;
int d0; int d0;
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.sc_mask) || if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
(_NSIG_WORDS > 1 && (_NSIG_WORDS > 1 &&
...@@ -392,7 +392,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused) ...@@ -392,7 +392,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
sigset_t set; sigset_t set;
int d0; int d0;
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;
......
...@@ -248,7 +248,7 @@ fix_alignment(struct pt_regs *regs) ...@@ -248,7 +248,7 @@ fix_alignment(struct pt_regs *regs)
*/ */
p = (long __user *) (regs->dar & -L1_CACHE_BYTES); p = (long __user *) (regs->dar & -L1_CACHE_BYTES);
if (user_mode(regs) if (user_mode(regs)
&& verify_area(VERIFY_WRITE, p, L1_CACHE_BYTES)) && !access_ok(VERIFY_WRITE, p, L1_CACHE_BYTES))
return -EFAULT; return -EFAULT;
for (i = 0; i < L1_CACHE_BYTES / sizeof(long); ++i) for (i = 0; i < L1_CACHE_BYTES / sizeof(long); ++i)
if (__put_user(0, p+i)) if (__put_user(0, p+i))
...@@ -328,7 +328,7 @@ fix_alignment(struct pt_regs *regs) ...@@ -328,7 +328,7 @@ fix_alignment(struct pt_regs *regs)
/* Verify the address of the operand */ /* Verify the address of the operand */
if (user_mode(regs)) { if (user_mode(regs)) {
if (verify_area((flags & ST? VERIFY_WRITE: VERIFY_READ), addr, nb)) if (!access_ok((flags & ST? VERIFY_WRITE: VERIFY_READ), addr, nb))
return -EFAULT; /* bad address */ return -EFAULT; /* bad address */
} }
......
...@@ -119,7 +119,7 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -119,7 +119,7 @@ sys_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_restorer, &act->sa_restorer)) __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
return -EFAULT; return -EFAULT;
...@@ -131,7 +131,7 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -131,7 +131,7 @@ sys_sigaction(int sig, const struct old_sigaction __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) {
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;
...@@ -377,7 +377,7 @@ handle_rt_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -377,7 +377,7 @@ handle_rt_signal(unsigned long sig, struct k_sigaction *ka,
/* create a stack frame for the caller of the handler */ /* create a stack frame for the caller of the handler */
newsp -= __SIGNAL_FRAMESIZE + 16; newsp -= __SIGNAL_FRAMESIZE + 16;
if (verify_area(VERIFY_WRITE, (void __user *) newsp, origsp - newsp)) if (!access_ok(VERIFY_WRITE, (void __user *) newsp, origsp - newsp))
goto badframe; goto badframe;
/* Put the siginfo & fill in most of the ucontext */ /* Put the siginfo & fill in most of the ucontext */
...@@ -446,7 +446,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -446,7 +446,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
return -EINVAL; return -EINVAL;
if (old_ctx != NULL) { if (old_ctx != NULL) {
if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx)) if (!access_ok(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
|| save_user_regs(regs, &old_ctx->uc_mcontext, 0) || save_user_regs(regs, &old_ctx->uc_mcontext, 0)
|| __copy_to_user(&old_ctx->uc_sigmask, || __copy_to_user(&old_ctx->uc_sigmask,
&current->blocked, sizeof(sigset_t)) &current->blocked, sizeof(sigset_t))
...@@ -455,7 +455,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -455,7 +455,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
} }
if (new_ctx == NULL) if (new_ctx == NULL)
return 0; return 0;
if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx)) if (!access_ok(VERIFY_READ, new_ctx, sizeof(*new_ctx))
|| __get_user(tmp, (u8 __user *) new_ctx) || __get_user(tmp, (u8 __user *) new_ctx)
|| __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1)) || __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1))
return -EFAULT; return -EFAULT;
...@@ -465,7 +465,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -465,7 +465,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
* image of the user's registers, we can't just return -EFAULT * image of the user's registers, we can't just return -EFAULT
* because the user's registers will be corrupted. For instance * because the user's registers will be corrupted. For instance
* the NIP value may have been updated but not some of the * the NIP value may have been updated but not some of the
* other registers. Given that we have done the verify_area * other registers. Given that we have done the access_ok
* and successfully read the first and last bytes of the region * and successfully read the first and last bytes of the region
* above, this should only happen in an out-of-memory situation * above, this should only happen in an out-of-memory situation
* or if another thread unmaps the region containing the context. * or if another thread unmaps the region containing the context.
...@@ -488,7 +488,7 @@ int sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, ...@@ -488,7 +488,7 @@ int sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
rt_sf = (struct rt_sigframe __user *) rt_sf = (struct rt_sigframe __user *)
(regs->gpr[1] + __SIGNAL_FRAMESIZE + 16); (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16);
if (verify_area(VERIFY_READ, rt_sf, sizeof(struct rt_sigframe))) if (!access_ok(VERIFY_READ, rt_sf, sizeof(struct rt_sigframe)))
goto bad; goto bad;
if (do_setcontext(&rt_sf->uc, regs, 1)) if (do_setcontext(&rt_sf->uc, regs, 1))
goto bad; goto bad;
...@@ -573,7 +573,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx, ...@@ -573,7 +573,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
* image of the user's registers, we can't just return -EFAULT * image of the user's registers, we can't just return -EFAULT
* because the user's registers will be corrupted. For instance * because the user's registers will be corrupted. For instance
* the NIP value may have been updated but not some of the * the NIP value may have been updated but not some of the
* other registers. Given that we have done the verify_area * other registers. Given that we have done the access_ok
* and successfully read the first and last bytes of the region * and successfully read the first and last bytes of the region
* above, this should only happen in an out-of-memory situation * above, this should only happen in an out-of-memory situation
* or if another thread unmaps the region containing the context. * or if another thread unmaps the region containing the context.
...@@ -623,7 +623,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -623,7 +623,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
/* create a stack frame for the caller of the handler */ /* create a stack frame for the caller of the handler */
newsp -= __SIGNAL_FRAMESIZE; newsp -= __SIGNAL_FRAMESIZE;
if (verify_area(VERIFY_WRITE, (void __user *) newsp, origsp - newsp)) if (!access_ok(VERIFY_WRITE, (void __user *) newsp, origsp - newsp))
goto badframe; goto badframe;
#if _NSIG != 64 #if _NSIG != 64
...@@ -681,7 +681,7 @@ int sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, ...@@ -681,7 +681,7 @@ int sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
restore_sigmask(&set); restore_sigmask(&set);
sr = (struct mcontext __user *) sigctx.regs; sr = (struct mcontext __user *) sigctx.regs;
if (verify_area(VERIFY_READ, sr, sizeof(*sr)) if (!access_ok(VERIFY_READ, sr, sizeof(*sr))
|| restore_user_regs(regs, sr, 1)) || restore_user_regs(regs, sr, 1))
goto badframe; goto badframe;
......
...@@ -77,7 +77,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif ...@@ -77,7 +77,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif
if (!ptr) if (!ptr)
break; break;
if ((ret = verify_area (VERIFY_READ, ptr, sizeof(long))) if ((ret = access_ok(VERIFY_READ, ptr, sizeof(long)) ? 0 : -EFAULT)
|| (ret = get_user(fourth.__pad, (void __user *__user *)ptr))) || (ret = get_user(fourth.__pad, (void __user *__user *)ptr)))
break; break;
ret = sys_semctl (first, second, third, fourth); ret = sys_semctl (first, second, third, fourth);
...@@ -93,7 +93,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif ...@@ -93,7 +93,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif
if (!ptr) if (!ptr)
break; break;
if ((ret = verify_area (VERIFY_READ, ptr, sizeof(tmp))) if ((ret = access_ok(VERIFY_READ, ptr, sizeof(tmp)) ? 0 : -EFAULT)
|| (ret = copy_from_user(&tmp, || (ret = copy_from_user(&tmp,
(struct ipc_kludge __user *) ptr, (struct ipc_kludge __user *) ptr,
sizeof (tmp)) ? -EFAULT : 0)) sizeof (tmp)) ? -EFAULT : 0))
...@@ -117,8 +117,8 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif ...@@ -117,8 +117,8 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif
case SHMAT: { case SHMAT: {
ulong raddr; ulong raddr;
if ((ret = verify_area(VERIFY_WRITE, (ulong __user *) third, if ((ret = access_ok(VERIFY_WRITE, (ulong __user *) third,
sizeof(ulong)))) sizeof(ulong)) ? 0 : -EFAULT))
break; break;
ret = do_shmat (first, (char __user *) ptr, second, &raddr); ret = do_shmat (first, (char __user *) ptr, second, &raddr);
if (ret) if (ret)
...@@ -213,7 +213,7 @@ ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s ...@@ -213,7 +213,7 @@ ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s
if ( (unsigned long)n >= 4096 ) if ( (unsigned long)n >= 4096 )
{ {
unsigned long __user *buffer = (unsigned long __user *)n; unsigned long __user *buffer = (unsigned long __user *)n;
if (verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long)) if (!access_ok(VERIFY_READ, buffer, 5*sizeof(unsigned long))
|| __get_user(n, buffer) || __get_user(n, buffer)
|| __get_user(inp, ((fd_set __user * __user *)(buffer+1))) || __get_user(inp, ((fd_set __user * __user *)(buffer+1)))
|| __get_user(outp, ((fd_set __user * __user *)(buffer+2))) || __get_user(outp, ((fd_set __user * __user *)(buffer+2)))
......
...@@ -273,7 +273,7 @@ fix_alignment(struct pt_regs *regs) ...@@ -273,7 +273,7 @@ fix_alignment(struct pt_regs *regs)
/* Verify the address of the operand */ /* Verify the address of the operand */
if (user_mode(regs)) { if (user_mode(regs)) {
if (verify_area((flags & ST? VERIFY_WRITE: VERIFY_READ), addr, nb)) if (!access_ok((flags & ST? VERIFY_WRITE: VERIFY_READ), addr, nb))
return -EFAULT; /* bad address */ return -EFAULT; /* bad address */
} }
......
...@@ -89,7 +89,7 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf, ...@@ -89,7 +89,7 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf,
return -ENODEV; return -ENODEV;
size = ppc_md.nvram_size(); size = ppc_md.nvram_size();
if (verify_area(VERIFY_WRITE, buf, count)) if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT; return -EFAULT;
if (*ppos >= size) if (*ppos >= size)
return 0; return 0;
...@@ -129,7 +129,7 @@ static ssize_t dev_nvram_write(struct file *file, const char __user *buf, ...@@ -129,7 +129,7 @@ static ssize_t dev_nvram_write(struct file *file, const char __user *buf,
return -ENODEV; return -ENODEV;
size = ppc_md.nvram_size(); size = ppc_md.nvram_size();
if (verify_area(VERIFY_READ, buf, count)) if (!access_ok(VERIFY_READ, buf, count))
return -EFAULT; return -EFAULT;
if (*ppos >= size) if (*ppos >= size)
return 0; return 0;
......
...@@ -224,7 +224,6 @@ static ssize_t rtas_flash_read(struct file *file, char *buf, ...@@ -224,7 +224,6 @@ static ssize_t rtas_flash_read(struct file *file, char *buf,
struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
struct rtas_update_flash_t *uf; struct rtas_update_flash_t *uf;
char msg[RTAS_MSG_MAXLEN]; char msg[RTAS_MSG_MAXLEN];
int error;
int msglen; int msglen;
uf = (struct rtas_update_flash_t *) dp->data; uf = (struct rtas_update_flash_t *) dp->data;
...@@ -241,8 +240,7 @@ static ssize_t rtas_flash_read(struct file *file, char *buf, ...@@ -241,8 +240,7 @@ static ssize_t rtas_flash_read(struct file *file, char *buf,
if (ppos && *ppos != 0) if (ppos && *ppos != 0)
return 0; /* be cheap */ return 0; /* be cheap */
error = verify_area(VERIFY_WRITE, buf, msglen); if (!access_ok(VERIFY_WRITE, buf, msglen))
if (error)
return -EINVAL; return -EINVAL;
if (copy_to_user(buf, msg, msglen)) if (copy_to_user(buf, msg, msglen))
...@@ -365,7 +363,6 @@ static ssize_t manage_flash_read(struct file *file, char *buf, ...@@ -365,7 +363,6 @@ static ssize_t manage_flash_read(struct file *file, char *buf,
struct rtas_manage_flash_t *args_buf; struct rtas_manage_flash_t *args_buf;
char msg[RTAS_MSG_MAXLEN]; char msg[RTAS_MSG_MAXLEN];
int msglen; int msglen;
int error;
args_buf = (struct rtas_manage_flash_t *) dp->data; args_buf = (struct rtas_manage_flash_t *) dp->data;
if (args_buf == NULL) if (args_buf == NULL)
...@@ -378,8 +375,7 @@ static ssize_t manage_flash_read(struct file *file, char *buf, ...@@ -378,8 +375,7 @@ static ssize_t manage_flash_read(struct file *file, char *buf,
if (ppos && *ppos != 0) if (ppos && *ppos != 0)
return 0; /* be cheap */ return 0; /* be cheap */
error = verify_area(VERIFY_WRITE, buf, msglen); if (!access_ok(VERIFY_WRITE, buf, msglen))
if (error)
return -EINVAL; return -EINVAL;
if (copy_to_user(buf, msg, msglen)) if (copy_to_user(buf, msg, msglen))
...@@ -477,7 +473,6 @@ static ssize_t validate_flash_read(struct file *file, char *buf, ...@@ -477,7 +473,6 @@ static ssize_t validate_flash_read(struct file *file, char *buf,
struct rtas_validate_flash_t *args_buf; struct rtas_validate_flash_t *args_buf;
char msg[RTAS_MSG_MAXLEN]; char msg[RTAS_MSG_MAXLEN];
int msglen; int msglen;
int error;
args_buf = (struct rtas_validate_flash_t *) dp->data; args_buf = (struct rtas_validate_flash_t *) dp->data;
...@@ -488,8 +483,7 @@ static ssize_t validate_flash_read(struct file *file, char *buf, ...@@ -488,8 +483,7 @@ static ssize_t validate_flash_read(struct file *file, char *buf,
if (msglen > count) if (msglen > count)
msglen = count; msglen = count;
error = verify_area(VERIFY_WRITE, buf, msglen); if (!access_ok(VERIFY_WRITE, buf, msglen))
if (error)
return -EINVAL; return -EINVAL;
if (copy_to_user(buf, msg, msglen)) if (copy_to_user(buf, msg, msglen))
...@@ -531,7 +525,7 @@ static ssize_t validate_flash_write(struct file *file, const char *buf, ...@@ -531,7 +525,7 @@ static ssize_t validate_flash_write(struct file *file, const char *buf,
args_buf->status = VALIDATE_INCOMPLETE; args_buf->status = VALIDATE_INCOMPLETE;
} }
if (verify_area(VERIFY_READ, buf, count)) { if (!access_ok(VERIFY_READ, buf, count)) {
rc = -EFAULT; rc = -EFAULT;
goto done; goto done;
} }
......
...@@ -289,8 +289,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf, ...@@ -289,8 +289,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
count = rtas_error_log_buffer_max; count = rtas_error_log_buffer_max;
error = verify_area(VERIFY_WRITE, buf, count); if (!access_ok(VERIFY_WRITE, buf, count))
if (error)
return -EFAULT; return -EFAULT;
tmp = kmalloc(count, GFP_KERNEL); tmp = kmalloc(count, GFP_KERNEL);
......
...@@ -73,7 +73,7 @@ static ssize_t scanlog_read(struct file *file, char *buf, ...@@ -73,7 +73,7 @@ static ssize_t scanlog_read(struct file *file, char *buf,
return -EINVAL; return -EINVAL;
} }
if (verify_area(VERIFY_WRITE, buf, count)) if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT; return -EFAULT;
for (;;) { for (;;) {
......
...@@ -316,7 +316,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -316,7 +316,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
return -EINVAL; return -EINVAL;
if (old_ctx != NULL) { if (old_ctx != NULL) {
if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx)) if (!access_ok(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
|| setup_sigcontext(&old_ctx->uc_mcontext, regs, 0, NULL, 0) || setup_sigcontext(&old_ctx->uc_mcontext, regs, 0, NULL, 0)
|| __copy_to_user(&old_ctx->uc_sigmask, || __copy_to_user(&old_ctx->uc_sigmask,
&current->blocked, sizeof(sigset_t))) &current->blocked, sizeof(sigset_t)))
...@@ -324,7 +324,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -324,7 +324,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
} }
if (new_ctx == NULL) if (new_ctx == NULL)
return 0; return 0;
if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx)) if (!access_ok(VERIFY_READ, new_ctx, sizeof(*new_ctx))
|| __get_user(tmp, (u8 __user *) new_ctx) || __get_user(tmp, (u8 __user *) new_ctx)
|| __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1)) || __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1))
return -EFAULT; return -EFAULT;
...@@ -334,7 +334,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -334,7 +334,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
* image of the user's registers, we can't just return -EFAULT * image of the user's registers, we can't just return -EFAULT
* because the user's registers will be corrupted. For instance * because the user's registers will be corrupted. For instance
* the NIP value may have been updated but not some of the * the NIP value may have been updated but not some of the
* other registers. Given that we have done the verify_area * other registers. Given that we have done the access_ok
* and successfully read the first and last bytes of the region * and successfully read the first and last bytes of the region
* above, this should only happen in an out-of-memory situation * above, this should only happen in an out-of-memory situation
* or if another thread unmaps the region containing the context. * or if another thread unmaps the region containing the context.
...@@ -366,7 +366,7 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -366,7 +366,7 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
/* Always make any pending restarted system calls return -EINTR */ /* Always make any pending restarted system calls return -EINTR */
current_thread_info()->restart_block.fn = do_no_restart_syscall; current_thread_info()->restart_block.fn = do_no_restart_syscall;
if (verify_area(VERIFY_READ, uc, sizeof(*uc))) if (!access_ok(VERIFY_READ, uc, sizeof(*uc)))
goto badframe; goto badframe;
if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
...@@ -406,7 +406,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, ...@@ -406,7 +406,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
frame = get_sigframe(ka, regs, sizeof(*frame)); frame = get_sigframe(ka, regs, sizeof(*frame));
if (verify_area(VERIFY_WRITE, frame, sizeof(*frame))) if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto badframe; goto badframe;
err |= __put_user(&frame->info, &frame->pinfo); err |= __put_user(&frame->info, &frame->pinfo);
......
...@@ -638,7 +638,7 @@ static int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, ...@@ -638,7 +638,7 @@ static int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
/* create a stack frame for the caller of the handler */ /* create a stack frame for the caller of the handler */
newsp -= __SIGNAL_FRAMESIZE32 + 16; newsp -= __SIGNAL_FRAMESIZE32 + 16;
if (verify_area(VERIFY_WRITE, (void __user *)newsp, origsp - newsp)) if (!access_ok(VERIFY_WRITE, (void __user *)newsp, origsp - newsp))
goto badframe; goto badframe;
compat_from_sigset(&c_oldset, oldset); compat_from_sigset(&c_oldset, oldset);
...@@ -728,7 +728,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx, ...@@ -728,7 +728,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx,
if (old_ctx != NULL) { if (old_ctx != NULL) {
compat_from_sigset(&c_set, &current->blocked); compat_from_sigset(&c_set, &current->blocked);
if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx)) if (!access_ok(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
|| save_user_regs(regs, &old_ctx->uc_mcontext, 0) || save_user_regs(regs, &old_ctx->uc_mcontext, 0)
|| __copy_to_user(&old_ctx->uc_sigmask, &c_set, sizeof(c_set)) || __copy_to_user(&old_ctx->uc_sigmask, &c_set, sizeof(c_set))
|| __put_user((u32)(u64)&old_ctx->uc_mcontext, &old_ctx->uc_regs)) || __put_user((u32)(u64)&old_ctx->uc_mcontext, &old_ctx->uc_regs))
...@@ -736,7 +736,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx, ...@@ -736,7 +736,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx,
} }
if (new_ctx == NULL) if (new_ctx == NULL)
return 0; return 0;
if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx)) if (!access_ok(VERIFY_READ, new_ctx, sizeof(*new_ctx))
|| __get_user(tmp, (u8 __user *) new_ctx) || __get_user(tmp, (u8 __user *) new_ctx)
|| __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1)) || __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1))
return -EFAULT; return -EFAULT;
...@@ -746,7 +746,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx, ...@@ -746,7 +746,7 @@ long sys32_swapcontext(struct ucontext32 __user *old_ctx,
* image of the user's registers, we can't just return -EFAULT * image of the user's registers, we can't just return -EFAULT
* because the user's registers will be corrupted. For instance * because the user's registers will be corrupted. For instance
* the NIP value may have been updated but not some of the * the NIP value may have been updated but not some of the
* other registers. Given that we have done the verify_area * other registers. Given that we have done the access_ok
* and successfully read the first and last bytes of the region * and successfully read the first and last bytes of the region
* above, this should only happen in an out-of-memory situation * above, this should only happen in an out-of-memory situation
* or if another thread unmaps the region containing the context. * or if another thread unmaps the region containing the context.
...@@ -770,7 +770,7 @@ long sys32_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, ...@@ -770,7 +770,7 @@ long sys32_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
rt_sf = (struct rt_sigframe32 __user *) rt_sf = (struct rt_sigframe32 __user *)
(regs->gpr[1] + __SIGNAL_FRAMESIZE32 + 16); (regs->gpr[1] + __SIGNAL_FRAMESIZE32 + 16);
if (verify_area(VERIFY_READ, rt_sf, sizeof(*rt_sf))) if (!access_ok(VERIFY_READ, rt_sf, sizeof(*rt_sf)))
goto bad; goto bad;
if (do_setcontext32(&rt_sf->uc, regs, 1)) if (do_setcontext32(&rt_sf->uc, regs, 1))
goto bad; goto bad;
...@@ -819,7 +819,7 @@ static int handle_signal32(unsigned long sig, struct k_sigaction *ka, ...@@ -819,7 +819,7 @@ static int handle_signal32(unsigned long sig, struct k_sigaction *ka,
/* create a stack frame for the caller of the handler */ /* create a stack frame for the caller of the handler */
newsp -= __SIGNAL_FRAMESIZE32; newsp -= __SIGNAL_FRAMESIZE32;
if (verify_area(VERIFY_WRITE, (void __user *) newsp, origsp - newsp)) if (!access_ok(VERIFY_WRITE, (void __user *) newsp, origsp - newsp))
goto badframe; goto badframe;
#if _NSIG != 64 #if _NSIG != 64
...@@ -892,7 +892,7 @@ long sys32_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, ...@@ -892,7 +892,7 @@ long sys32_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
restore_sigmask(&set); restore_sigmask(&set);
sr = (struct mcontext32 __user *)(u64)sigctx.regs; sr = (struct mcontext32 __user *)(u64)sigctx.regs;
if (verify_area(VERIFY_READ, sr, sizeof(*sr)) if (!access_ok(VERIFY_READ, sr, sizeof(*sr))
|| restore_user_regs(regs, sr, 1)) || restore_user_regs(regs, sr, 1))
goto badframe; goto badframe;
......
...@@ -241,7 +241,7 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf) ...@@ -241,7 +241,7 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
!new_valid_dev(stat->rdev)) !new_valid_dev(stat->rdev))
return -EOVERFLOW; return -EOVERFLOW;
err = verify_area(VERIFY_WRITE, statbuf, sizeof(*statbuf)); err = access_ok(VERIFY_WRITE, statbuf, sizeof(*statbuf)) ? 0 : -EFAULT;
err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev); err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
err |= __put_user(stat->ino, &statbuf->st_ino); err |= __put_user(stat->ino, &statbuf->st_ino);
err |= __put_user(stat->mode, &statbuf->st_mode); err |= __put_user(stat->mode, &statbuf->st_mode);
...@@ -1195,7 +1195,7 @@ unsigned long sys32_mmap2(unsigned long addr, size_t len, ...@@ -1195,7 +1195,7 @@ unsigned long sys32_mmap2(unsigned long addr, size_t len,
int get_compat_timeval(struct timeval *tv, struct compat_timeval __user *ctv) int get_compat_timeval(struct timeval *tv, struct compat_timeval __user *ctv)
{ {
return (verify_area(VERIFY_READ, ctv, sizeof(*ctv)) || return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) ||
__get_user(tv->tv_sec, &ctv->tv_sec) || __get_user(tv->tv_sec, &ctv->tv_sec) ||
__get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
} }
......
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