

This is the patch that converts verify_area to access_ok for the x86_64 
and ia64 archs.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/ia64/ia32/ia32_signal.c   |    6 +++---
 25-akpm/arch/ia64/ia32/sys_ia32.c      |   12 +++++-------
 25-akpm/arch/ia64/kernel/ptrace.c      |   18 ++++--------------
 25-akpm/arch/x86_64/ia32/ia32_aout.c   |    4 ++--
 25-akpm/arch/x86_64/ia32/ia32_signal.c |    6 +++---
 25-akpm/arch/x86_64/ia32/sys_ia32.c    |   18 +++++++++---------
 25-akpm/arch/x86_64/kernel/signal.c    |    4 ++--
 7 files changed, 28 insertions(+), 40 deletions(-)

diff -puN arch/ia64/ia32/ia32_signal.c~verify_area-cleanup-x86_64-and-ia64 arch/ia64/ia32/ia32_signal.c
--- 25/arch/ia64/ia32/ia32_signal.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/ia64/ia32/ia32_signal.c	2005-03-03 22:09:41.000000000 -0800
@@ -778,7 +778,7 @@ restore_sigcontext_ia32 (struct pt_regs 
 		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
 	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, 
 	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;
diff -puN arch/ia64/ia32/sys_ia32.c~verify_area-cleanup-x86_64-and-ia64 arch/ia64/ia32/sys_ia32.c
--- 25/arch/ia64/ia32/sys_ia32.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/ia64/ia32/sys_ia32.c	2005-03-03 22:09:41.000000000 -0800
@@ -2402,12 +2402,11 @@ sys32_epoll_ctl(int epfd, int op, int fd
 {
 	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_
 	}
 
 	/* 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
diff -puN arch/ia64/kernel/ptrace.c~verify_area-cleanup-x86_64-and-ia64 arch/ia64/kernel/ptrace.c
--- 25/arch/ia64/kernel/ptrace.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/ptrace.c	2005-03-03 22:09:41.000000000 -0800
@@ -1074,15 +1074,12 @@ ptrace_getregs (struct task_struct *chil
 	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 *chil
 	    || 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 *chil
 	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 *chil
 		return -EIO;
 	}
 
-	retval = 0;
-
 	/* control regs */
 
 	retval |= __get_user(pt->cr_iip, &ppr->cr_iip);
diff -puN arch/x86_64/ia32/ia32_aout.c~verify_area-cleanup-x86_64-and-ia64 arch/x86_64/ia32/ia32_aout.c
--- 25/arch/x86_64/ia32/ia32_aout.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/x86_64/ia32/ia32_aout.c	2005-03-03 22:09:41.000000000 -0800
@@ -182,9 +182,9 @@ static int aout_core_dump(long signr, st
 
 /* 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);
diff -puN arch/x86_64/ia32/ia32_signal.c~verify_area-cleanup-x86_64-and-ia64 arch/x86_64/ia32/ia32_signal.c
--- 25/arch/x86_64/ia32/ia32_signal.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/x86_64/ia32/ia32_signal.c	2005-03-03 22:09:41.000000000 -0800
@@ -256,7 +256,7 @@ ia32_restore_sigcontext(struct pt_regs *
 		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 p
 	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(struc
 
 	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;
diff -puN arch/x86_64/ia32/sys_ia32.c~verify_area-cleanup-x86_64-and-ia64 arch/x86_64/ia32/sys_ia32.c
--- 25/arch/x86_64/ia32/sys_ia32.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/x86_64/ia32/sys_ia32.c	2005-03-03 22:09:41.000000000 -0800
@@ -85,7 +85,7 @@ int cp_compat_stat(struct kstat *kbuf, s
 		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, st
 	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 sigac
 	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 sigac
 			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_sig
 		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_sig
         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 *i
 		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 *ut
 
 	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 *ut
 
 	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) ||
diff -puN arch/x86_64/kernel/signal.c~verify_area-cleanup-x86_64-and-ia64 arch/x86_64/kernel/signal.c
--- 25/arch/x86_64/kernel/signal.c~verify_area-cleanup-x86_64-and-ia64	2005-03-03 22:09:41.000000000 -0800
+++ 25-akpm/arch/x86_64/kernel/signal.c	2005-03-03 22:09:41.000000000 -0800
@@ -121,7 +121,7 @@ restore_sigcontext(struct pt_regs *regs,
 		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 
 	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))) { 
_
