diff options
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r-- | block/scsi_ioctl.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 9a87daa6f4f..4f4230b79bb 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/capability.h> | 24 | #include <linux/capability.h> |
25 | #include <linux/completion.h> | 25 | #include <linux/completion.h> |
26 | #include <linux/cdrom.h> | 26 | #include <linux/cdrom.h> |
27 | #include <linux/ratelimit.h> | ||
28 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
29 | #include <linux/times.h> | 28 | #include <linux/times.h> |
30 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
@@ -566,7 +565,7 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod | |||
566 | { | 565 | { |
567 | int err; | 566 | int err; |
568 | 567 | ||
569 | if (!q) | 568 | if (!q || blk_get_queue(q)) |
570 | return -ENXIO; | 569 | return -ENXIO; |
571 | 570 | ||
572 | switch (cmd) { | 571 | switch (cmd) { |
@@ -687,64 +686,11 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod | |||
687 | err = -ENOTTY; | 686 | err = -ENOTTY; |
688 | } | 687 | } |
689 | 688 | ||
689 | blk_put_queue(q); | ||
690 | return err; | 690 | return err; |
691 | } | 691 | } |
692 | EXPORT_SYMBOL(scsi_cmd_ioctl); | 692 | EXPORT_SYMBOL(scsi_cmd_ioctl); |
693 | 693 | ||
694 | int scsi_verify_blk_ioctl(struct block_device *bd, unsigned int cmd) | ||
695 | { | ||
696 | if (bd && bd == bd->bd_contains) | ||
697 | return 0; | ||
698 | |||
699 | /* Actually none of these is particularly useful on a partition, | ||
700 | * but they are safe. | ||
701 | */ | ||
702 | switch (cmd) { | ||
703 | case SCSI_IOCTL_GET_IDLUN: | ||
704 | case SCSI_IOCTL_GET_BUS_NUMBER: | ||
705 | case SCSI_IOCTL_GET_PCI: | ||
706 | case SCSI_IOCTL_PROBE_HOST: | ||
707 | case SG_GET_VERSION_NUM: | ||
708 | case SG_SET_TIMEOUT: | ||
709 | case SG_GET_TIMEOUT: | ||
710 | case SG_GET_RESERVED_SIZE: | ||
711 | case SG_SET_RESERVED_SIZE: | ||
712 | case SG_EMULATED_HOST: | ||
713 | return 0; | ||
714 | case CDROM_GET_CAPABILITY: | ||
715 | /* Keep this until we remove the printk below. udev sends it | ||
716 | * and we do not want to spam dmesg about it. CD-ROMs do | ||
717 | * not have partitions, so we get here only for disks. | ||
718 | */ | ||
719 | return -ENOIOCTLCMD; | ||
720 | default: | ||
721 | break; | ||
722 | } | ||
723 | |||
724 | if (capable(CAP_SYS_RAWIO)) | ||
725 | return 0; | ||
726 | |||
727 | /* In particular, rule out all resets and host-specific ioctls. */ | ||
728 | printk_ratelimited(KERN_WARNING | ||
729 | "%s: sending ioctl %x to a partition!\n", current->comm, cmd); | ||
730 | |||
731 | return -ENOIOCTLCMD; | ||
732 | } | ||
733 | EXPORT_SYMBOL(scsi_verify_blk_ioctl); | ||
734 | |||
735 | int scsi_cmd_blk_ioctl(struct block_device *bd, fmode_t mode, | ||
736 | unsigned int cmd, void __user *arg) | ||
737 | { | ||
738 | int ret; | ||
739 | |||
740 | ret = scsi_verify_blk_ioctl(bd, cmd); | ||
741 | if (ret < 0) | ||
742 | return ret; | ||
743 | |||
744 | return scsi_cmd_ioctl(bd->bd_disk->queue, bd->bd_disk, mode, cmd, arg); | ||
745 | } | ||
746 | EXPORT_SYMBOL(scsi_cmd_blk_ioctl); | ||
747 | |||
748 | static int __init blk_scsi_ioctl_init(void) | 694 | static int __init blk_scsi_ioctl_init(void) |
749 | { | 695 | { |
750 | blk_set_cmd_filter_defaults(&blk_default_cmd_filter); | 696 | blk_set_cmd_filter_defaults(&blk_default_cmd_filter); |