• Paolo Bonzini's avatar
    block: fail SCSI passthrough ioctls on partition devices · 8bd8442f
    Paolo Bonzini authored
    commit 0bfc96cb upstream.
    
    [ Changes with respect to 3.3: return -ENOTTY from scsi_verify_blk_ioctl
      and -ENOIOCTLCMD from sd_compat_ioctl. ]
    
    Linux allows executing the SG_IO ioctl on a partition or LVM volume, and
    will pass the command to the underlying block device.  This is
    well-known, but it is also a large security problem when (via Unix
    permissions, ACLs, SELinux or a combination thereof) a program or user
    needs to be granted access only to part of the disk.
    
    This patch lets partitions forward a small set of harmless ioctls;
    others are logged with printk so that we can see which ioctls are
    actually sent.  In my tests only CDROM_GET_CAPABILITY actually occurred.
    Of course it was being sent to a (partition on a) hard disk, so it would
    have failed with ENOTTY and the patch isn't changing anything in
    practice.  Still, I'm treating it specially to avoid spamming the logs.
    
    In principle, this restriction should incl...
    8bd8442f
scsi_ioctl.c 19.6 KB