Bug 752375 (CVE-2011-4127) - CVE-2011-4127 kernel: possible privilege escalation via SG_IO ioctl
Summary: CVE-2011-4127 kernel: possible privilege escalation via SG_IO ioctl
Status: CLOSED ERRATA
Alias: CVE-2011-4127
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard: impact=important,public=20111222,repo...
Keywords: Security
Depends On: 752379 752380 752385 752386 756677 756678 757071 760412 761383 767721 768469 769911 772018 783031
Blocks: 751423
TreeView+ depends on / blocked
 
Reported: 2011-11-09 10:54 UTC by Petr Matousek
Modified: 2019-06-08 18:58 UTC (History)
42 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2015-08-23 13:33:29 UTC


Attachments (Terms of Use)
CVE-2011-4127-rhel-6-patchset (4.12 KB, application/x-gzip)
2011-12-22 17:19 UTC, Petr Matousek
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1849 normal SHIPPED_LIVE Important: kernel security and bug fix update 2011-12-22 23:15:49 UTC
Red Hat Product Errata RHSA-2011:1850 normal SHIPPED_LIVE Important: rhev-hypervisor6 security and bug fix update 2011-12-22 22:23:38 UTC
Red Hat Product Errata RHSA-2012:0107 normal SHIPPED_LIVE Important: kernel security and bug fix update 2012-02-09 21:37:09 UTC
Red Hat Product Errata RHSA-2012:0333 normal SHIPPED_LIVE Important: kernel-rt security and bug fix update 2012-02-24 01:21:35 UTC
Red Hat Product Errata RHSA-2012:0358 normal SHIPPED_LIVE Important: kernel security and bug fix update 2012-03-06 22:42:05 UTC

Description Petr Matousek 2011-11-09 10:54:36 UTC
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

Comment 21 Petr Matousek 2011-11-23 11:10:00 UTC
rhel-5 doesn't implement SG_IO passthrough in virtio-blk (unlike rhel-6) which leaves us with potential local privilege escalation "only".

Comment 51 Petr Matousek 2011-12-22 10:03:47 UTC
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.

Comment 52 Alasdair Kergon 2011-12-22 15:20:22 UTC
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.

Comment 53 Petr Matousek 2011-12-22 15:32:58 UTC
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

Comment 56 Petr Matousek 2011-12-22 17:19:35 UTC
Created attachment 549226 [details]
CVE-2011-4127-rhel-6-patchset

Comment 57 Petr Matousek 2011-12-22 17:24:20 UTC
Created kernel tracking bugs for this issue

Affects: fedora-all [bug 769911]

Comment 58 errata-xmlrpc 2011-12-22 17:26:06 UTC
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

Comment 59 errata-xmlrpc 2011-12-22 18:18:05 UTC
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

Comment 60 Petr Matousek 2011-12-22 20:20:32 UTC
Upstream discussion:

https://lkml.org/lkml/2011/12/22/270

Comment 61 Murray McAllister 2011-12-23 03:53:10 UTC
(Comment 53 content copied to knowledgebase: https://access.redhat.com/kb/docs/DOC-67874)

Comment 64 errata-xmlrpc 2012-02-09 16:41:38 UTC
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

Comment 65 errata-xmlrpc 2012-02-23 20:23:23 UTC
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

Comment 66 errata-xmlrpc 2012-03-06 17:43:37 UTC
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


Note You need to log in before you can comment on or make changes to this bug.