]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: add and use scsi_blk_cmd_ioctl
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 Jan 2012 15:01:27 +0000 (16:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 Feb 2012 14:40:54 +0000 (15:40 +0100)
commit 577ebb374c78314ac4617242f509e2f5e7156649 upstream.

Introduce a wrapper around scsi_cmd_ioctl that takes a block device.

The function will then be enhanced to detect partition block devices
and, in that case, subject the ioctls to whitelisting.

Cc: linux-scsi@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Cc: James Bottomley <JBottomley@parallels.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
[bwh: Backport to 2.6.32 - adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[wt: slightly changed the interface to match 2.6.27's scsi_cmd_ioctl()
     which still needs the file pointer but has no mode parameter].

Signed-off-by: Willy Tarreau <w@1wt.eu>
block/scsi_ioctl.c
drivers/block/cciss.c
drivers/block/ub.c
drivers/block/virtio_blk.c
drivers/cdrom/cdrom.c
drivers/ide/ide-floppy.c
drivers/scsi/sd.c
include/linux/blkdev.h

index dd3281a5fb5f8effb4bba4958c6e82626b610143..29dc026ca315fd05b76573879868ea52edbe25b0 100644 (file)
@@ -653,3 +653,11 @@ int scsi_cmd_ioctl(struct file *file, struct request_queue *q,
 }
 
 EXPORT_SYMBOL(scsi_cmd_ioctl);
+
+int scsi_cmd_blk_ioctl(struct file *file, struct block_device *bd,
+                       unsigned int cmd, void __user *arg)
+{
+       return scsi_cmd_ioctl(file, bd->bd_disk->queue, bd->bd_disk, cmd, arg);
+}
+EXPORT_SYMBOL(scsi_cmd_blk_ioctl);
+
index ee1eb5e831b3d4ad75e9b7bc9c78da42230822dd..efe615f31695428d03a0de619ba9733bc8006975 100644 (file)
@@ -1225,7 +1225,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                        return status;
                }
 
-       /* scsi_cmd_ioctl handles these, below, though some are not */
+       /* scsi_cmd_blk_ioctl handles these, below, though some are not */
        /* very meaningful for cciss.  SG_IO is the main one people want. */
 
        case SG_GET_VERSION_NUM:
@@ -1236,9 +1236,9 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
        case SG_EMULATED_HOST:
        case SG_IO:
        case SCSI_IOCTL_SEND_COMMAND:
-               return scsi_cmd_ioctl(filep, disk->queue, disk, cmd, argp);
+               return scsi_cmd_blk_ioctl(filep, bdev, cmd, argp);
 
-       /* scsi_cmd_ioctl would normally handle these, below, but */
+       /* scsi_cmd_blk_ioctl would normally handle these, below, but */
        /* they aren't a good fit for cciss, as CD-ROMs are */
        /* not supported, and we don't have any bus/target/lun */
        /* which we present to the kernel. */
index 3a281ef11ffa9a96543358dc91c817805eedc981..a05a76feb98b6401e0a600cab12361669bd1cfff 100644 (file)
@@ -1729,10 +1729,9 @@ static int ub_bd_release(struct inode *inode, struct file *filp)
 static int ub_bd_ioctl(struct inode *inode, struct file *filp,
     unsigned int cmd, unsigned long arg)
 {
-       struct gendisk *disk = inode->i_bdev->bd_disk;
        void __user *usermem = (void __user *) arg;
 
-       return scsi_cmd_ioctl(filp, disk->queue, disk, cmd, usermem);
+       return scsi_cmd_blk_ioctl(filp, inode->i_bdev, cmd, usermem);
 }
 
 /*
index 42251095134fa7746e8748150089c2dd570d21d8..e498a9d8c0ff0455936f31ce6d9919dc1b0c9107 100644 (file)
@@ -149,8 +149,7 @@ static void do_virtblk_request(struct request_queue *q)
 static int virtblk_ioctl(struct inode *inode, struct file *filp,
                         unsigned cmd, unsigned long data)
 {
-       return scsi_cmd_ioctl(filp, inode->i_bdev->bd_disk->queue,
-                             inode->i_bdev->bd_disk, cmd,
+       return scsi_cmd_blk_ioctl(filp, inode->i_bdev, cmd,
                              (void __user *)data);
 }
 
index 74031de517e6f342e070f7c8d5e057f7e10c78aa..ba79dac01aced2e3b91dd275c1bde1167581ac1b 100644 (file)
@@ -2667,12 +2667,11 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
 {
        void __user *argp = (void __user *)arg;
        int ret;
-       struct gendisk *disk = ip->i_bdev->bd_disk;
 
        /*
         * Try the generic SCSI command ioctl's first.
         */
-       ret = scsi_cmd_ioctl(file, disk->queue, disk, cmd, argp);
+       ret = scsi_cmd_blk_ioctl(file, ip->i_bdev, cmd, argp);
        if (ret != -ENOTTY)
                return ret;
 
index e9034c0125f3e32440d2d0d2a9de9fd067eada09..f773f5936cef7d96272247934298f67036dc4f2d 100644 (file)
@@ -1337,8 +1337,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
         * and CDROM_SEND_PACKET (legacy) ioctls
         */
        if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
-               err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
-                                       bdev->bd_disk, cmd, argp);
+               err = scsi_cmd_blk_ioctl(file, bdev, cmd, argp);
        else
                err = -ENOTTY;
 
index 00751a1296eb409c8422f6e2e47b872f1e9b2cef..92fb11478b0de24c10119848cd8f41ac03cb63e6 100644 (file)
@@ -769,7 +769,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
                case SCSI_IOCTL_GET_BUS_NUMBER:
                        return scsi_ioctl(sdp, cmd, p);
                default:
-                       error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p);
+                       error = scsi_cmd_blk_ioctl(filp, bdev, cmd, p);
                        if (error != -ENOTTY)
                                return error;
        }
index 73f4532373b8fe1dbdde00eed8620ab52b60ee90..1a20bb0d43b7d4b0fd6576afee6d8ec87977093a 100644 (file)
@@ -671,6 +671,8 @@ extern int blk_remove_plug(struct request_queue *);
 extern void blk_recount_segments(struct request_queue *, struct bio *);
 extern int scsi_cmd_ioctl(struct file *, struct request_queue *,
                          struct gendisk *, unsigned int, void __user *);
+extern int scsi_cmd_blk_ioctl(struct file *, struct block_device *,
+                              unsigned int, void __user *);
 extern int sg_scsi_ioctl(struct file *, struct request_queue *,
                struct gendisk *, struct scsi_ioctl_command __user *);