patch-2.1.10 linux/net/ipv4/rarp.c

Next file: linux/net/ipv4/raw.c
Previous file: linux/net/ipv4/packet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.9/linux/net/ipv4/rarp.c linux/net/ipv4/rarp.c
@@ -289,9 +289,12 @@
 	unsigned long ip;
 	struct rtable *rt;
 	struct device * dev;
+	int err; 
   
-	copy_from_user(&r, req, sizeof(r));
-  
+	err = copy_from_user(&r, req, sizeof(r));
+	if (err)
+		return -EFAULT;
+
 	/*
 	 *	We only understand about IP addresses... 
 	 */
@@ -390,13 +393,16 @@
 	struct rarp_table *entry;
 	struct sockaddr_in *si;
 	unsigned long ip;
-
+	int err; 
+	
 /*
  *	We only understand about IP addresses...
  */
         
-	copy_from_user(&r, req, sizeof(r));
-  
+	err = copy_from_user(&r, req, sizeof(r));
+	if (err)
+		return -EFAULT; 
+
 	if (r.arp_pa.sa_family != AF_INET)
 		return -EPFNOSUPPORT;
   
@@ -430,8 +436,7 @@
  *        Copy the information back
  */
   
-	copy_to_user(req, &r, sizeof(r));
-	return 0;
+	return copy_to_user(req, &r, sizeof(r));
 }
 
 
@@ -450,10 +455,9 @@
 		case SIOCDRARP:
 			if (!suser())
 				return -EPERM;
-			err = verify_area(VERIFY_READ, arg, sizeof(struct arpreq));
-			if(err)
-				return err;
-			copy_from_user(&r, arg, sizeof(r));
+			err = copy_from_user(&r, arg, sizeof(r));
+			if (err)
+				return -EFAULT; 
 			if (r.arp_pa.sa_family != AF_INET)
 				return -EPFNOSUPPORT;
 			si = (struct sockaddr_in *) &r.arp_pa;
@@ -461,16 +465,11 @@
 			return 0;
 
 		case SIOCGRARP:
-			err = verify_area(VERIFY_WRITE, arg, sizeof(struct arpreq));
-			if(err)
-				return err;
+
 			return rarp_req_get((struct arpreq *)arg);
 		case SIOCSRARP:
 			if (!suser())
 				return -EPERM;
-			err = verify_area(VERIFY_READ, arg, sizeof(struct arpreq));
-			if(err)
-				return err;
 			return rarp_req_set((struct arpreq *)arg);
 		default:
 			return -EINVAL;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov