Xen Security Advisory 227 (CVE-2017-12137) - x86: PV privilege escalation via map_grant_ref
Xen.org security team <[email protected]>
| Newsgroups | gmane.comp.emulators.xen.announce |
|---|---|
| Message-ID | <E1dhabV-0006du-B7__41243.4629085057$1502799159$gmane$org@xenbits.xenproject.org> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Xen Security Advisory CVE-2017-12137 / XSA-227
version 3
x86: PV privilege escalation via map_grant_ref
UPDATES IN VERSION 3
====================
Public release.
ISSUE DESCRIPTION
=================
When mapping a grant reference, a guest must inform Xen of where it
would like the grant mapped. For PV guests, this is done by nominating
an existing linear address, or an L1 pagetable entry, to be altered.
Neither of these PV paths check for alignment of the passed parameter.
The linear address path suitably truncates the linear address when
calculating the L1 entry to use, but the path which uses a directly
nominated L1 entry performs no checks.
This causes Xen to make an incorrectly-aligned update to a pagetable,
which corrupts both the intended entry and the subsequent entry with
values which are largely guest controlled. If the misaligned value
crosses a page boundary, then an arbitrary other heap page is
corrupted.
IMPACT
======
A PV guest can elevate its privilege to that of the host.
VULNERABLE SYSTEMS
==================
All versions of Xen are vulnerable.
Only x86 systems are vulnerable.
Any system running untrusted PV guests is vulnerable.
The vulnerability is exposed to PV stub qemu serving as the device model
for HVM guests. Our default assumption is that an HVM guest has
compromised its PV stub qemu. By extension, it is likely that the
vulnerability is exposed to HVM guests which are served by a PV stub
qemu.
MITIGATION
==========
Running only HVM guests, served by a dom0-based qemu, will avoid this
vulnerability.
CREDITS
=======
This issue was discovered by Andrew Cooper of Citrix.
RESOLUTION
==========
Applying the appropriate attached patch resolves this issue.
xsa227.patch xen-unstable, Xen 4.9.x, 4.8.x, 4.7.x
xsa227-4.6.patch Xen 4.6.x
xsa227-4.5.patch Xen 4.5.x
$ sha256sum xsa227*
c48cc3be47e81a4ceebcf60659b8755516c68916fc5150920ed42c6b61e3f219 xsa227.meta
9923a47e5f86949800887596f098954a08ef73a01d74b1dbe16cab2e6b1fabb2 xsa227.patch
6f83d0d9ff853192840d2b82d26d8fde21473bf4ac1441a153f3ee02efd1dd67 xsa227-4.5.patch
162b991b27b86f210089526a01cae715563d3a069c92f42538b423bba7709fcc xsa227-4.6.patch
$
(The .meta file is a prototype machine-readable file for describing
which patches are to be applied how.)
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
iQEcBAEBCAAGBQJZkuNOAAoJEIP+FMlX6CvZ9wsH/3/DA8EENxPdhgoNEihvHgPP
rquggFGcmgiJZyuy6+e3PZKUwQmUcVdPuVE5h+8NWYRCTjxa15LC/auAmkMHP170
f7nkSA6oU0zT1mxxqWWjht+CCJ56dmpJN+WGXQMasVEO9PLYR7gOxf90rqDuzqE8
zcQA4OyIOpsEH4Y2k2hjYFeLleWSLZKSPAy8fupZv34FakZDDLgxPMdWSrYQX/pP
r2QmLoVk4pSQYZzy5aAZWgLugR+ewOmgYTntzGYSEB2VqEgl6vtA8STVqB5WsYZ4
eumUUZRBUeo9n2U9TgWPmKr5JtvC9w2/cjV6HysO5vUwuLJUICX25O9BE3VnBs0=
=ulEd
-----END PGP SIGNATURE-----
_______________________________________________
Xen-announce mailing list
[email protected]
https://lists.xen.org/xen-announce
xsa227.meta
(application/octet-stream, 1.8 KB) - not displayed
xsa227.patch
(application/octet-stream, 1.5 KB)
From fa7268b94f8a0a7792ee12d5b8e23a60e52a3a84 Mon Sep 17 00:00:00 2001 From: Andrew Cooper <[email protected]> Date: Tue, 20 Jun 2017 19:18:54 +0100 Subject: [PATCH] x86/grant: Disallow misaligned PTEs Pagetable entries must be aligned to function correctly. Disallow attempts from the guest to have a grant PTE created at a misaligned address, which would result in corruption of the L1 table with largely-guest-controlled values. This is XSA-227 Signed-off-by: Andrew Cooper <[email protected]> Reviewed-by: Jan Beulich <[email protected]> --- xen/arch/x86/mm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 97b3b4b..00f517a 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3763,6 +3763,9 @@ static int create_grant_pte_mapping( l1_pgentry_t ol1e; struct domain *d = v->domain; + if ( !IS_ALIGNED(pte_addr, sizeof(nl1e)) ) + return GNTST_general_error; + adjust_guest_l1e(nl1e, d); gmfn = pte_addr >> PAGE_SHIFT; @@ -3819,6 +3822,16 @@ static int destroy_grant_pte_mapping( struct page_info *page; l1_pgentry_t ol1e; + /* + * addr comes from Xen's active_entry tracking so isn't guest controlled, + * but it had still better be PTE-aligned. + */ + if ( !IS_ALIGNED(addr, sizeof(ol1e)) ) + { + ASSERT_UNREACHABLE(); + return GNTST_general_error; + } + gmfn = addr >> PAGE_SHIFT; page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC); -- 2.1.4
xsa227-4.5.patch
(application/octet-stream, 1.9 KB)
From 3aab881c7331cf93ffd8d2f2dd9adfd18ed4fc99 Mon Sep 17 00:00:00 2001 From: Andrew Cooper <[email protected]> Date: Tue, 20 Jun 2017 19:18:54 +0100 Subject: [PATCH] x86/grant: Disallow misaligned PTEs Pagetable entries must be aligned to function correctly. Disallow attempts from the guest to have a grant PTE created at a misaligned address, which would result in corruption of the L1 table with largely-guest-controlled values. This is XSA-227 Signed-off-by: Andrew Cooper <[email protected]> Reviewed-by: Jan Beulich <[email protected]> --- xen/arch/x86/mm.c | 13 +++++++++++++ xen/include/xen/config.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 70bf52f60a..70dfec5af1 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3781,6 +3781,9 @@ static int create_grant_pte_mapping( l1_pgentry_t ol1e; struct domain *d = v->domain; + if ( !IS_ALIGNED(pte_addr, sizeof(nl1e)) ) + return GNTST_general_error; + adjust_guest_l1e(nl1e, d); gmfn = pte_addr >> PAGE_SHIFT; @@ -3838,6 +3841,16 @@ static int destroy_grant_pte_mapping( struct page_info *page; l1_pgentry_t ol1e; + /* + * addr comes from Xen's active_entry tracking so isn't guest controlled, + * but it had still better be PTE-aligned. + */ + if ( !IS_ALIGNED(addr, sizeof(ol1e)) ) + { + ASSERT_UNREACHABLE(); + return GNTST_general_error; + } + gmfn = addr >> PAGE_SHIFT; page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC); diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h index 7bef8a648d..a3aa1d4832 100644 --- a/xen/include/xen/config.h +++ b/xen/include/xen/config.h @@ -82,6 +82,8 @@ #endif /* !__ASSEMBLY__ */ +#define IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0) + #define __STR(...) #__VA_ARGS__ #define STR(...) __STR(__VA_ARGS__) -- 2.13.2
xsa227-4.6.patch
(application/octet-stream, 1.9 KB)
From 697edc414352e89f29ca3de744a76c1625c0466c Mon Sep 17 00:00:00 2001 From: Andrew Cooper <[email protected]> Date: Tue, 20 Jun 2017 19:18:54 +0100 Subject: [PATCH] x86/grant: Disallow misaligned PTEs Pagetable entries must be aligned to function correctly. Disallow attempts from the guest to have a grant PTE created at a misaligned address, which would result in corruption of the L1 table with largely-guest-controlled values. This is XSA-227 Signed-off-by: Andrew Cooper <[email protected]> Reviewed-by: Jan Beulich <[email protected]> --- xen/arch/x86/mm.c | 13 +++++++++++++ xen/include/xen/config.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 213b52a..3bf728b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3878,6 +3878,9 @@ static int create_grant_pte_mapping( l1_pgentry_t ol1e; struct domain *d = v->domain; + if ( !IS_ALIGNED(pte_addr, sizeof(nl1e)) ) + return GNTST_general_error; + adjust_guest_l1e(nl1e, d); gmfn = pte_addr >> PAGE_SHIFT; @@ -3935,6 +3938,16 @@ static int destroy_grant_pte_mapping( struct page_info *page; l1_pgentry_t ol1e; + /* + * addr comes from Xen's active_entry tracking so isn't guest controlled, + * but it had still better be PTE-aligned. + */ + if ( !IS_ALIGNED(addr, sizeof(ol1e)) ) + { + ASSERT_UNREACHABLE(); + return GNTST_general_error; + } + gmfn = addr >> PAGE_SHIFT; page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC); diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h index f7258c7..ded8156 100644 --- a/xen/include/xen/config.h +++ b/xen/include/xen/config.h @@ -72,6 +72,8 @@ #define MB(_mb) (_AC(_mb, ULL) << 20) #define GB(_gb) (_AC(_gb, ULL) << 30) +#define IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0) + #define __STR(...) #__VA_ARGS__ #define STR(...) __STR(__VA_ARGS__) -- 2.1.4