patch-2.3.10 linux/fs/ioctl.c

Next file: linux/fs/locks.c
Previous file: linux/fs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.9/linux/fs/ioctl.c linux/fs/ioctl.c
@@ -25,6 +25,8 @@
 				return -EBADF;
 		    	if (inode->i_op->get_block == NULL)
 				return -EINVAL;
+			if (!capable(CAP_SYS_RAWIO))
+				return -EPERM;
 			if ((error = get_user(block, (int *) arg)) != 0)
 				return error;
 
@@ -52,11 +54,11 @@
 	unsigned int flag;
 	int on, error = -EBADF;
 
-	lock_kernel();
 	filp = fget(fd);
 	if (!filp)
 		goto out;
 	error = 0;
+	lock_kernel();
 	switch (cmd) {
 		case FIOCLEX:
 			FD_SET(fd, &current->files->close_on_exec);
@@ -107,8 +109,8 @@
 				error = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
 	}
 	fput(filp);
+	unlock_kernel();
 
 out:
-	unlock_kernel();
 	return error;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)