]> www.infradead.org Git - users/jedix/linux-maple.git/commit
[block] fail SCSI passthrough ioctls on partition devices
authorJoe Jin <joe.jin@oracle.com>
Fri, 23 Dec 2011 01:59:41 +0000 (09:59 +0800)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Thu, 17 May 2012 17:51:45 +0000 (10:51 -0700)
commitf02116914fe36105c0bdd7b4be627c8c15389ef2
tree3a5ef848e343c2d7fff50133a7618353d5f4f075
parent6607b9702874e36212c5bcd80c6d24f0c236cf45
[block] fail SCSI passthrough ioctls on partition devices

CVE-2011-4127.

Linux allows executing the SG_IO ioctl on a partition or even on an
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 to a particular partition or logical
volume but not to the full device.

This patch limits the ioctls that are forwarded to non-SCSI devices to
a few ones that are harmless.  This restriction includes programs
running with the CAP_SYS_RAWIO.  If for example I let a program access
/dev/sda2 and /dev/sdb, it still should not be able to read/write outside
the boundaries of /dev/sda2 independent of the capabilities.

This patch does not affect the non-libata IDE driver.  That driver however
alreadys test for bd != bd->bd_contains before issuing some ioctl; so,
programs that do not require CAP_SYS_RAWIO are safe.  A workaround is
just to use libata.

Encryption on the host is a mitigating factor, but it does not provide
a full solution.  In particular it doesn't protect against DoS (write
random data), replay attacks (reinstate old ciphertext sectors), or
writes to unencrypted areas including the MBR, the partition table, or
/boot.

Thanks to Daniel Berrange, Milan Broz, Mike Christie, Alasdair Kergon,
Petr Matousek, Jeff Moyer, Mike Snitzer and others for help discussing
this issue.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
block/scsi_ioctl.c
drivers/scsi/sd.c
include/linux/blkdev.h