patch-2.1.7 linux/fs/ioctl.c

Next file: linux/fs/ncpfs/ncplib_kernel.h
Previous file: linux/drivers/scsi/scsi.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.6/linux/fs/ioctl.c linux/fs/ioctl.c
@@ -25,27 +25,18 @@
 				return -EBADF;
 		    	if (filp->f_inode->i_op->bmap == NULL)
 				return -EINVAL;
-			error = verify_area(VERIFY_WRITE,(void *) arg,4);
-			if (error)
+			if ((error = get_user(block, (int *) arg)) != 0)
 				return error;
-			get_user(block, (int *) arg);
 			block = filp->f_inode->i_op->bmap(filp->f_inode,block);
-			put_user(block,(int *) arg);
-			return 0;
+			return put_user(block, (int *) arg);
 		case FIGETBSZ:
 			if (filp->f_inode->i_sb == NULL)
 				return -EBADF;
-			error = verify_area(VERIFY_WRITE,(void *) arg,4);
-			if (error)
-				return error;
-			put_user(filp->f_inode->i_sb->s_blocksize, (int *) arg);
-			return 0;
+			return put_user(filp->f_inode->i_sb->s_blocksize,
+					(int *) arg);
 		case FIONREAD:
-			error = verify_area(VERIFY_WRITE,(void *) arg,sizeof(int));
-			if (error)
-				return error;
-			put_user(filp->f_inode->i_size - filp->f_pos, (int *) arg);
-			return 0;
+			return put_user(filp->f_inode->i_size - filp->f_pos,
+					(int *) arg);
 	}
 	if (filp->f_op && filp->f_op->ioctl)
 		return filp->f_op->ioctl(filp->f_inode, filp, cmd, arg);
@@ -56,7 +47,7 @@
 asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {	
 	struct file * filp;
-	int on;
+	int on, error;
 
 	if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
 		return -EBADF;
@@ -70,11 +61,8 @@
 			return 0;
 
 		case FIONBIO:
-			on = verify_area(VERIFY_READ, (unsigned int *)arg,
-				sizeof(unsigned int));
-			if(on)	
-				return on;
-			get_user(on, (unsigned int *) arg);
+			if ((error = get_user(on, (int *)arg)) != 0)
+				return error;
 			if (on)
 				filp->f_flags |= O_NONBLOCK;
 			else
@@ -83,11 +71,8 @@
 
 		case FIOASYNC: /* O_SYNC is not yet implemented,
 				  but it's here for completeness. */
-			on = verify_area(VERIFY_READ, (unsigned int *)arg,
-				sizeof(unsigned int));
-			if(on)	
-				return on;
-			get_user(on, (unsigned int *) arg);
+			if ((error = get_user(on, (int *)arg)) != 0)
+				return error;
 			if (on)
 				filp->f_flags |= O_SYNC;
 			else

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