Skip to contentSkip to conversation

Xen Security Advisory 148 (CVE-2015-7835) - x86: Uncontrolled creation of large page mappings by PV guests

PATCH Xen.org security team 1 participant 1 message Oct 29, 2015

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Xen Security Advisory CVE-2015-7835 / XSA-148
version 4

x86: Uncontrolled creation of large page mappings by PV guests

UPDATES IN VERSION 4
====================

Public release.

ISSUE DESCRIPTION
=================

The code to validate level 2 page table entries is bypassed when certain conditions are satisfied. This means that a PV guest can create writeable mappings using super page mappings.

Such writeable mappings can violate Xen intended invariants for pages which Xen is supposed to keep read-only.

This is possible even if the "allowsuperpage" command line option is not used.

IMPACT
======

Malicious PV guest administrators can escalate privilege so as to control the whole system.

VULNERABLE SYSTEMS
==================

Xen 3.4 and onward are vulnerable.

Only x86 systems are vulnerable. ARM systems are not vulnerable.

Only PV guests can exploit the vulnerability. Both 32-bit and 64-bit PV guests can do so.

MITIGATION
==========

Running only HVM guests will avoid this vulnerability.

On systems where the guest kernel is controlled by the host rather than guest administrator, running only kernels which do not call these hypercalls will also prevent untrusted guest users from exploiting this issue. However untrusted guest administrators can still trigger it unless further steps are taken to prevent them from loading code into the kernel (e.g. by disabling loadable modules etc) or from using other mechanisms which allow them to run code at kernel privilege.

CREDITS
=======

This issue was discovered by 栾尚聪 (好风) of Alibaba.

RESOLUTION
==========

Applying the appropriate attached patch resolves this issue.

xsa148.patch                 xen-unstable, Xen 4.6.x
xsa148-4.5.patch             Xen 4.5.x
xsa148-4.4.patch             Xen 4.4.x, Xen 4.3.x
$ sha256sum xsa148*.patch
f320d105a4832124910f46c50acd4803fe289bd7c4702ec15f97fb611b70944d  xsa148.patch
7f78efd001f041a0e5502546664d28011cb881d72c94ea564585efb3ca01ddfe  xsa148-4.4.patch
272a729048471cea851d4a881f3f2c32c7be101e2a452d2b2ceb9d66908ee4a3  xsa148-4.5.patch
$

DEPLOYMENT DURING EMBARGO
=========================

Deployment of the patches and/or mitigations described above (or others which are substantially similar) is permitted during the embargo, even on public-facing systems with untrusted guest users and administrators.

But: Distribution of updated software is prohibited (except to other members of the predisclosure list).

Predisclosure list members who wish to deploy significantly different patches and/or mitigations, please contact the Xen Project Security Team.

(Note: this during-embargo deployment notice is retained in post-embargo publicly released Xen Project advisories, even though it is then no longer applicable. This is to enable the community to have oversight of the Xen Project Security Team's decisionmaking.)

For more information about permissible uses of embargoed information, consult the Xen Project community's agreed Security Policy:
http://www.xenproject.org/security-policy.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJWMgm4AAoJEIP+FMlX6CvZPl0IAI7uPHn9OiDqQlKnvuF5DJkx WkmX6lNgIXd9arkZ2gUvlenPArfJV2Rv75TP/0LLuITrv+AcylFEBd7T7rdbXeAT w5TaYI1wnixu8D+klyMGDjIt8Oy0gG1D8tpJYB4SETmT/Knv9FmFmUrShPD5kEVW 6W3j3PulCpPX6+8rpmD+1CD8DDH/FHvr3xc/mK9gaWTSfPvYX0wcUbVR5GK63SHy 6smdmcbyMz6RLlq9MRSs1ifYuAOFel3bFi0NaUm+w3luVozgg6MiEopmnmLZXgbu 93iMDiKbQmr6XdsqvqWexJ7hAiWD5Sp+ztUW0iyNLKpj482VU9wSm0vwneZpgCg= =WDZi
-----END PGP SIGNATURE-----

x86: guard against undue super page PTE creation

When optional super page support got added (commit bd1cd81d64 "x86: PV support for hugepages"), two adjustments were missed: mod_l2_entry() needs to consider the PSE and RW bits when deciding whether to use the fast path, and the PSE bit must not be removed from L2_DISALLOW_MASK unconditionally.

This is XSA-148.

xen/arch/x86/mm.c +8 -2
@@ -160,7 +160,10 @@ static void put_superpage(unsigned long 
 static uint32_t base_disallow_mask;
 /* Global bit is allowed to be set on L1 PTEs. Intended for user mappings. */
 #define L1_DISALLOW_MASK ((base_disallow_mask | _PAGE_GNTTAB) & ~_PAGE_GLOBAL)
-#define L2_DISALLOW_MASK (base_disallow_mask & ~_PAGE_PSE)
+
+#define L2_DISALLOW_MASK (unlikely(opt_allow_superpage) \
+                          ? base_disallow_mask & ~_PAGE_PSE \
+                          : base_disallow_mask)
 
 #define l3_disallow_mask(d) (!is_pv_32bit_domain(d) ? \
                              base_disallow_mask : 0xFFFFF198U)
@@ -1841,7 +1844,10 @@ static int mod_l2_entry(l2_pgentry_t *pl
         }
 
         /* Fast path for identical mapping and presence. */
-        if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT) )
+        if ( !l2e_has_changed(ol2e, nl2e,
+                              unlikely(opt_allow_superpage)
+                              ? _PAGE_PSE | _PAGE_RW | _PAGE_PRESENT
+                              : _PAGE_PRESENT) )
         {
             adjust_guest_l2e(nl2e, d);
             if ( UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, preserve_ad) )

x86: guard against undue super page PTE creation

When optional super page support got added (commit bd1cd81d64 "x86: PV support for hugepages"), two adjustments were missed: mod_l2_entry() needs to consider the PSE and RW bits when deciding whether to use the fast path, and the PSE bit must not be removed from L2_DISALLOW_MASK unconditionally.

This is XSA-148.

xen/arch/x86/mm.c +8 -2
@@ -163,7 +163,10 @@ static void put_superpage(unsigned long 
 
 static uint32_t base_disallow_mask;
 #define L1_DISALLOW_MASK (base_disallow_mask | _PAGE_GNTTAB)
-#define L2_DISALLOW_MASK (base_disallow_mask & ~_PAGE_PSE)
+
+#define L2_DISALLOW_MASK (unlikely(opt_allow_superpage) \
+                          ? base_disallow_mask & ~_PAGE_PSE \
+                          : base_disallow_mask)
 
 #define l3_disallow_mask(d) (!is_pv_32on64_domain(d) ?  \
                              base_disallow_mask :       \
@@ -1786,7 +1789,10 @@ static int mod_l2_entry(l2_pgentry_t *pl
         }
 
         /* Fast path for identical mapping and presence. */
-        if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT) )
+        if ( !l2e_has_changed(ol2e, nl2e,
+                              unlikely(opt_allow_superpage)
+                              ? _PAGE_PSE | _PAGE_RW | _PAGE_PRESENT
+                              : _PAGE_PRESENT) )
         {
             adjust_guest_l2e(nl2e, d);
             if ( UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, preserve_ad) )

x86: guard against undue super page PTE creation

When optional super page support got added (commit bd1cd81d64 "x86: PV support for hugepages"), two adjustments were missed: mod_l2_entry() needs to consider the PSE and RW bits when deciding whether to use the fast path, and the PSE bit must not be removed from L2_DISALLOW_MASK unconditionally.

This is XSA-148.

xen/arch/x86/mm.c +8 -2
@@ -162,7 +162,10 @@ static void put_superpage(unsigned long 
 static uint32_t base_disallow_mask;
 /* Global bit is allowed to be set on L1 PTEs. Intended for user mappings. */
 #define L1_DISALLOW_MASK ((base_disallow_mask | _PAGE_GNTTAB) & ~_PAGE_GLOBAL)
-#define L2_DISALLOW_MASK (base_disallow_mask & ~_PAGE_PSE)
+
+#define L2_DISALLOW_MASK (unlikely(opt_allow_superpage) \
+                          ? base_disallow_mask & ~_PAGE_PSE \
+                          : base_disallow_mask)
 
 #define l3_disallow_mask(d) (!is_pv_32on64_domain(d) ?  \
                              base_disallow_mask :       \
@@ -1770,7 +1773,10 @@ static int mod_l2_entry(l2_pgentry_t *pl
         }
 
         /* Fast path for identical mapping and presence. */
-        if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT) )
+        if ( !l2e_has_changed(ol2e, nl2e,
+                              unlikely(opt_allow_superpage)
+                              ? _PAGE_PSE | _PAGE_RW | _PAGE_PRESENT
+                              : _PAGE_PRESENT) )
         {
             adjust_guest_l2e(nl2e, d);
             if ( UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, vcpu, preserve_ad) )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel