mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
block: add and use scsi_blk_cmd_ioctl
commit 577ebb374c
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>
This commit is contained in:
parent
d172827c67
commit
7d06495983
@ -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);
|
||||
|
||||
|
@ -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. */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user