patch-2.1.4 linux/fs/read_write.c

Next file: linux/fs/readdir.c
Previous file: linux/fs/proc/scsi.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.3/linux/fs/read_write.c linux/fs/read_write.c
@@ -90,19 +90,17 @@
 	if (origin > 2)
 		goto bad;
 
-	retval = verify_area(VERIFY_WRITE, result, sizeof(offset));
-	if (retval)
-		goto bad;
-
 	offset = llseek(inode, file,
 		(((unsigned long long) offset_high << 32) | offset_low),
 		origin);
 
 	retval = offset;
 	if (offset >= 0) {
-		put_user(offset, result);
-		retval = 0;
+		retval = copy_to_user(result, &offset, sizeof(offset));
+		if (retval)
+			retval = -EFAULT;
 	}
+
 bad:
 	return retval;
 }
@@ -127,9 +125,6 @@
 	error = locks_verify_area(FLOCK_VERIFY_READ,inode,file,file->f_pos,count);
 	if (error)
 		goto out;
-	error = verify_area(VERIFY_WRITE,buf,count);
-	if (error)
-		goto out;
 	error = -EINVAL;
 	if (!file->f_op || !(read = file->f_op->read))
 		goto out;
@@ -159,9 +154,6 @@
 	error = locks_verify_area(FLOCK_VERIFY_WRITE,inode,file,file->f_pos,count);
 	if (error)
 		goto out;
-	error = verify_area(VERIFY_READ,buf,count);
-	if (error)
-		goto out;
 	error = -EINVAL;
 	if (!file->f_op || !(write = file->f_op->write))
 		goto out;
@@ -220,17 +212,11 @@
 		return 0;
 	if (count > UIO_MAXIOV)
 		return -EINVAL;
-	retval = verify_area(VERIFY_READ, vector, count*sizeof(*vector));
-	if (retval)
-		return retval;
-	memcpy_fromfs(iov, vector, count*sizeof(*vector));
+	if (copy_from_user(iov, vector, count*sizeof(*vector)))
+		return -EFAULT;
 	tot_len = 0;
-	for (i = 0 ; i < count ; i++) {
+	for (i = 0 ; i < count ; i++)
 		tot_len += iov[i].iov_len;
-		retval = verify_area(type, iov[i].iov_base, iov[i].iov_len);
-		if (retval)
-			return retval;
-	}
 
 	retval = locks_verify_area(type == VERIFY_READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
 				   inode, file, file->f_pos, tot_len);

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