Paolo Bonzini of Red Hat found out that the host Linux system 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 could be further exploited in the context of virtualization, because virtio disks support a limited form of SCSI passthrough via the SG_IO ioctl. If virtio disk is hosted on a partition or LVM volume with format=raw, tools such as sg_dd can be used to read and write other data on the same disk --- even data that belongs to the host or to other guests. References: https://lkml.org/lkml/2004/8/12/218 https://lkml.org/lkml/2004/8/12/260
rhel-5 doesn't implement SG_IO passthrough in virtio-blk (unlike rhel-6) which leaves us with potential local privilege escalation "only".
Statement: This issue affects the Linux kernel as shipped with Red Hat Enterprise Linux 4, 5, 6, and Red Hat Enterprise MRG. This has been addressed in Red Hat Enterprise Linux 5, 6, and Red Hat Enterprise MRG via https://rhn.redhat.com/errata/RHSA-2012-0107.html, https://rhn.redhat.com/errata/RHSA-2011-1849.html, and https://rhn.redhat.com/errata/RHSA-2012-0333.html. Red Hat Enterprise Linux 4 is now in Production 3 of the maintenance life-cycle, https://access.redhat.com/support/policy/updates/errata/, therefore the fix for this issue is not currently planned to be included in the future updates.
For a storage stack to be vulnerable, every layer must forward the SG_IO ioctls to the layer below it. Three device-mapper target types are known to do this: linear, multipath and flakey. If the I/O has to pass through striped, crypt, mirror or snapshot* device-mapper target types or an md software raid layer on its route to disk, any SG_IO will get blocked by those layers and so we believe such configurations are not vulnerable.
Issue It was found that using the SG_IO IOCTL to issue SCSI requests to partitions or LVM volumes resulted in the requests being passed to the underlying block device. If a privileged user only had access to a single partition or LVM volume, they could use this flaw to bypass those restrictions and gain read and write access (and be able to issue other SCSI commands) to the entire block device. In KVM virtualization environments that use raw format virtio disks backed by a partition or LVM volume, a privileged guest user could use this flaw to bypass intended access restrictions and issue read and write requests (and other SCSI commands) on the host, and possibly access the data of other guests that reside on the same underlying block device. Partition-based and LVM-based storage pools are not used by default. Refer to the "11. Storage pools" chapter of the Red Hat Enterprise Linux 6 "Virtualization Administration Guide", available from docs.redhat.com, for information about storage pools. Any driver that uses the SCSI framework is vulnerable. A physical SCSI device is not required to exploit this issue. Environment * Red Hat Enterprise Linux 5 and 6. * Red Hat Enterprise Virtualization Hypervisor 6.2. The virtualization aspect of this issue (privileged guests users reading and writing data on the host and other guests on the same underlying block device) does not affect users of KVM (or the Xen hypervisor) on Red Hat Enterprise Linux 5. Resolution The RHSA-2011:1849 update for Red Hat Enterprise Linux 6 corrected this issue. Future updates will correct this issue for Red Hat Enterprise Linux 5 and Red Hat Enterprise Virtualization Hypervisor 6.2. It is not possible to use control groups (cgroups) or sVirt mandatory access control to mitigate this issue. For virtualization hosts (including Red Hat Enterprise Virtualization Hypervisor 6.2), before updates are applied, the following SystemTap script prevents privileged guest users from issuing read and write requests (and other SCSI commands) on the host and possibly access the data of other guests that reside on the same underlying block device. 1) On the host, save the following in a file with the ".stp" extension: #!/usr/sbin/stap -g # Requires guru mode (-g) for target variable writes probe syscall.ioctl { SG_IO = 0x2285 if($cmd == SG_IO && execname() == "qemu-kvm") { printf("filtering SG_IO ioctl request from qemu-kvm process %d\n", pid()) $cmd = 0x0 $fd = -1 } } 2) Install the "systemtap" package and any required dependencies. Refer to the "2. Using SystemTap" chapter in the Red Hat Enterprise Linux 5 and 6 "SystemTap Beginners Guide" documents, available from docs.redhat.com, for information on installing the required -debuginfo packages. 3) Run the "stap -g [filename-from-step-1].stp" command as root. If the host is rebooted, the changes will be lost and the script must be run again. Further assistance If you require assistance with mitigating this issue, contact Red Hat Support: https://access.redhat.com/support/contact/technicalSupport.html
Created attachment 549226 [details] CVE-2011-4127-rhel-6-patchset
Created kernel tracking bugs for this issue Affects: fedora-all [bug 769911]
This issue has been addressed in following products: RHEV-H and Agents for RHEL-6 Via RHSA-2011:1850 https://rhn.redhat.com/errata/RHSA-2011-1850.html
This issue has been addressed in following products: Red Hat Enterprise Linux 6 Via RHSA-2011:1849 https://rhn.redhat.com/errata/RHSA-2011-1849.html
Upstream discussion: https://lkml.org/lkml/2011/12/22/270
(Comment 53 content copied to knowledgebase: https://access.redhat.com/kb/docs/DOC-67874)
This issue has been addressed in following products: Red Hat Enterprise Linux 5 Via RHSA-2012:0107 https://rhn.redhat.com/errata/RHSA-2012-0107.html
This issue has been addressed in following products: MRG for RHEL-6 v.2 Via RHSA-2012:0333 https://rhn.redhat.com/errata/RHSA-2012-0333.html
This issue has been addressed in following products: Red Hat Enterprise Linux 5.6 EUS - Server Only Via RHSA-2012:0358 https://rhn.redhat.com/errata/RHSA-2012-0358.html