summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-01-10 10:54:52 -0500
committerJens Axboe <axboe@kernel.dk>2018-01-10 14:30:37 -0500
commit0478fe68685a428c71decc19abecd265a6d658dd (patch)
tree6657bf4a8000bdaa4deea628627dcca99a007821 /block
parent7c3fb70f0341f9d924818e648906774921f4bcb3 (diff)
block: silently forbid sending any ioctl to a partition
After the first few months, the message has not led to many bug reports. It's been almost five years now, and in practice the main source of it seems to be MTIOCGET that someone is using to detect tape devices. While we could whitelist it just like CDROM_GET_CAPABILITY, this patch just removes the message altogether. The patch also removes the "safe but not very useful" ioctl whitelist, as suggested by Christoph. I doubt anything is using most of those ioctls _in general_, let alone on a partition. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/scsi_ioctl.c29
1 files changed, 0 insertions, 29 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 5cddff44a2f8..60b471f8621b 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -693,38 +693,9 @@ int scsi_verify_blk_ioctl(struct block_device *bd, unsigned int cmd)
693 if (bd && bd == bd->bd_contains) 693 if (bd && bd == bd->bd_contains)
694 return 0; 694 return 0;
695 695
696 /* Actually none of these is particularly useful on a partition,
697 * but they are safe.
698 */
699 switch (cmd) {
700 case SCSI_IOCTL_GET_IDLUN:
701 case SCSI_IOCTL_GET_BUS_NUMBER:
702 case SCSI_IOCTL_GET_PCI:
703 case SCSI_IOCTL_PROBE_HOST:
704 case SG_GET_VERSION_NUM:
705 case SG_SET_TIMEOUT:
706 case SG_GET_TIMEOUT:
707 case SG_GET_RESERVED_SIZE:
708 case SG_SET_RESERVED_SIZE:
709 case SG_EMULATED_HOST:
710 return 0;
711 case CDROM_GET_CAPABILITY:
712 /* Keep this until we remove the printk below. udev sends it
713 * and we do not want to spam dmesg about it. CD-ROMs do
714 * not have partitions, so we get here only for disks.
715 */
716 return -ENOIOCTLCMD;
717 default:
718 break;
719 }
720
721 if (capable(CAP_SYS_RAWIO)) 696 if (capable(CAP_SYS_RAWIO))
722 return 0; 697 return 0;
723 698
724 /* In particular, rule out all resets and host-specific ioctls. */
725 printk_ratelimited(KERN_WARNING
726 "%s: sending ioctl %x to a partition!\n", current->comm, cmd);
727
728 return -ENOIOCTLCMD; 699 return -ENOIOCTLCMD;
729} 700}
730EXPORT_SYMBOL(scsi_verify_blk_ioctl); 701EXPORT_SYMBOL(scsi_verify_blk_ioctl);