Skip to contentSkip to conversation

Xen Security Advisory 543 v1 (CVE-2026-142564) - x86: insufficient grant unmapping checks for HVM domains

PATCH Xen.org security team 1 participant 1 message Dec 3

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Xen Security Advisory CVE-2026-142564 / XSA-543

x86: insufficient grant unmapping checks for HVM domains

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

Grants allow a domain to map pages of another domain, either read-only or writable. When an x86 HVM or PVH guest unmaps a grant, Xen checks that the address given by the guest holds a grant mapping of the right page, but not whether that mapping is the read-only or the writable one.

A HVM/PVH domain which has the same page mapped both writable and read-only can therefore ask Xen to remove its writable mapping while naming the read-only one. Xen then no longer accounts for a writable mapping, but the guest still has it.

This is the same problem that XSA-234 fixed for PV guests.

IMPACT
======

A domain can retain an unaccounted writable mapping to a page. This can lead to privilege escalation, Denial of Service (DoS) affecting the entire host, and information leaks.

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

Xen versions 4.0 and onwards are vulnerable. Xen versions 3.4 and older are not vulnerable.

Only x86 systems are vulnerable. Arm systems are not vulnerable.

Only HVM and PVH domains can leverage the vulnerability.

MITIGATION
==========

There is no known mitigation.

CREDITS
=======

This issue was discovered by an automated scan run by AMD.

RESOLUTION
==========

Applying the attached patch resolves this issue.

Note that patches for released versions are generally prepared to apply to the stable branches, and may not apply cleanly to the most recent release tarball. Downstreams are encouraged to update to the tip of the stable branch before applying these patches.

xsa543.patch xen-unstable - Xen 4.17.x

$ sha256sum xsa543*
615a54b90403e655756fa984738097ee35e334550e7ce5a8e433fe8c8e77e5c4  xsa543.patch
$

NOTE REGARDING LACK OF EMBARGO
==============================

The issue was (also) reported in public.
-----BEGIN PGP SIGNATURE-----

iQFABAEBCAAqFiEEI+MiLBRfRHX6gGCng/4UyVfoK9kFAmsR3RoMHHBncEB4ZW4u b3JnAAoJEIP+FMlX6CvZRq4H/2M0qRDDGj7UDLSmrnm7g+gUslArIzcNKl53asma XWqI31w2dQ6DknZMthHDBJvvorWUxEvcqpSNYqYKc6X4BZDfjfg8JozpHi9WBtLL 4FmmQ2cSv8HBj0TUmuDQIGryexxQGM8zICTlumOSCeFyZL9YcQ0hTjYyWWYi+TcW Lbjpw0AeLQZSwOdTf9aqVH1sMM6MuFe8iLjlIuDpxAIjl5H79O0BUuvPruuQ6leY 76biUX5No27HhXIOuJwJd5QYxzGEdqAk0cRm87/VopPhMb2VZ+O7B4cbnEsTg7x5 Fith5amVEHpvy2uv7vUy7Ao8kUwud3oFh+Xvnvpbf93nAkQ=
=l8Fd
-----END PGP SIGNATURE-----

From: Roger Pau Monne <[email protected]>
Date: Thu, 3 Dec 2026 17:53:44 +0100
Subject: [PATCH] x86/hvm: check the type of grant mappings on unmap
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When a grant is unmapped from an HVM/PVH guest, Xen removes the p2m entry at the address supplied by the guest and releases the pin held by the mapping handle. replace_grant_p2m_mapping() only checks that the entry at that address is a grant mapping of the expected frame, not whether it's a read-only or a read-write one.

A guest having the same frame mapped both read-write and read-only can hence unmap the read-write handle while passing the address of the read-only mapping. The write pin is then dropped, together with the writable type reference if one was taken, while the read-write p2m entry stays in place backed only by the read pin of the other handle.

Refuse the unmap unless the type of the p2m entry matches the flags the handle was mapped with. The flags passed to the function are already those of the existing mapping, so no new parameter is needed.

This is the HVM counterpart of XSA-234, which added the equivalent check for PV guests in 16b1414de91b ("gnttab: also validate PTE permissions upon destroy/replace").

This is XSA-543 / CVE-2026-142564

Fixes b37d30c8fc52 ("Mapping grant references into HVM guests, take 2")
---
 xen/arch/x86/hvm/grant_table.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/grant_table.c +3 -2
index afe449d8882c..fa8c17199da4 100644
@@ -38,7 +38,8 @@ int replace_grant_p2m_mapping(uint64_t addr, mfn_t frame,
                               uint64_t new_addr, unsigned int flags)
 {
     unsigned long gfn = (unsigned long)(addr >> PAGE_SHIFT);
-    p2m_type_t type;
+    p2m_type_t type, exp_type = (flags & GNTMAP_readonly) ? p2m_grant_map_ro
+                                                          : p2m_grant_map_rw;
     mfn_t old_mfn;
     struct domain *d = current->domain;
 
@@ -46,7 +47,7 @@ int replace_grant_p2m_mapping(uint64_t addr, mfn_t frame,
         return GNTST_general_error;
 
     old_mfn = get_gfn_query(d, gfn, &type);
-    if ( !p2m_is_grant(type) || !mfn_eq(old_mfn, frame) )
+    if ( type != exp_type || !mfn_eq(old_mfn, frame) )
     {
         put_gfn(d, gfn);
         gdprintk(XENLOG_WARNING,
Signature · 1 line
2.55.0