Xen Security Advisory 519 v2 (CVE-2026-102699,CVE-2026-102702) - Arm: multiple issues with GNTTABOP_cache_flush
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Xen Security Advisory CVE-2026-102699,CVE-2026-102702 / XSA-519
version 2
Arm: multiple issues with GNTTABOP_cache_flush
UPDATES IN VERSION 2
====================
Public release.
ISSUE DESCRIPTION
=================
1) XSA-437 (CVE-2023-34321) addressed issues with overflows in calculations involved in guests flushing caches through GNTTABOP_cache_flush. Unfortunately the fix there introduced a calculation which may underflow, resulting in a loop which would - at least on 64-bit Arm - take excessively long, and which would likely eventually crash the hypervisor.
This is CVE-2026-102699.
2) GNTTABOP_cache_flush may be issued on memory mapped from another domain using the grant table interface. However there was no restriction to disallow the use of invalidate-without-clean against read-only grant mappings, which may corrupt the granted memory.
This is CVE-2026-102702.
IMPACT
======
A malicious unprivileged guest may crash the hypervisor, causing a Denial of Service (DoS) affecting the entire host, or corrupt memory belonging to another domain. Privilege escalation and information leaks cannot be ruled out.
VULNERABLE SYSTEMS
==================
All Xen versions from 4.5 onwards are vulnerable. Xen versions 4.4 and earlier are not vulnerable.
Only Arm systems are vulnerable. x86 systems are not vulnerable.
MITIGATION
==========
There is no known mitigation.
CREDITS
=======
CVE-2026-102699 was discovered by Leonid Komarianskyi of EPAM. It was later independently reported by Ayan Kumar Halder of AMD.
CVE-2026-102702 was found by the security team while looking at the surrounding code.
RESOLUTION
==========
Applying the appropriate 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.
xsa519-?.patch xen-unstable - Xen 4.21.x
xsa519-4.20-?.patch Xen 4.20.x - Xen 4.17.x
$ sha256sum xsa519* 3abfe7776402ba82d54b72163427694055cc3a5a729fd50a15af58699fef7903 xsa519-1.patch 6f09a24c5c793570e290ec853220099c617e372d96b93f938439ac4a18191dd2 xsa519-2.patch 1ed852f7e22fafe75e278dc913377fda5b0b73c8af51fe872684eb5b0bcb9597 xsa519-4.20-1.patch df5ba864761f3274df817fa362e234afb4b5e3f95b47daf25a307ac3d922aab6 xsa519-4.20-2.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-----
iQFABAEBCAAqFiEEI+MiLBRfRHX6gGCng/4UyVfoK9kFAmrOIrAMHHBncEB4ZW4u b3JnAAoJEIP+FMlX6CvZ9ccIALBHbUY7GDoW1oFxKSpvrFFzwdSeq+yR7Y+cnBy7 6j9ehJE2zC1qLqHy0MQjFcmdSvdm/1Qy4CZ+cZgKtOMCeOvV8OwA6QkuHV5fch0f 2wHq71u/9p7wWhsILb9EHaUHBFNXiQ+joahKPyX4FHwz2aCB+aodqCRMsvk0Kd7K PSX4FotvGHSfgxrdzP6oLPOrmvVwy91ienOabE7QMTW2anghDIFVfjycYuebfXxF S+d7ciAcHdd72fOhM/wVlXZohslxw14ESJYZMUOvha8godQjPwCtT/A/SDc/k0Et 98xImFp4NU9W4Pk42eS+JUs3KNLWFapzVePRQ0Ku80Ia6wg=
=xgyt
-----END PGP SIGNATURE-----
From: Leonid Komarianskyi <[email protected]>
Subject: xen/arm: Fix size underflow in invalidate_dcache_va_range()
When the start address is not cacheline aligned, the bytes covered by the first, partial cacheline are subtracted from 'size'. Nothing checks that the region actually extends beyond that cacheline, so if it does not, the unsigned subtraction underflows and the loop that follows walks practically the entire address space.
For example, with a 64-byte cacheline, p = 0x40000001 and size = 1:
p & cacheline_mask -> 1, so the partial head is taken
size -= 64 - 1 -> 1 - 63 underflows to 0xffffffffffffffc2Instead of a single "dc civac" at 0x40000000, the loop then runs 288230376151711743 times, issuing "dc ivac" from 0x40000040 upwards. Invalidating without cleaning discards dirty cachelines, so this corrupts whatever is mapped along the way until Xen takes a data abort.
Moreover, _cache_flush() in common/grant_table.c, reachable from a guest via GNTTABOP_cache_flush, bounds 'offset' and 'length' against the page size but requires no alignment, so GNTTAB_CACHE_INVAL with offset = 1 and length = 1 is enough to trigger this. Note that the page may belong to a different domain (the d != owner path), so the data being discarded is not necessarily the caller's own.
The subtraction dates back to the fix for XSA-437, so this is a regression in that change.
Fix this by detecting the underflow instead of letting it happen: if the region ends inside the first cacheline, there is nothing left to flush and the function bails out right after cleaning it. Partially covered cachelines are still cleaned as well as invalidated, so that data outside of the region is not discarded.
Additionally, drop 'idx' and advance 'p' directly instead. It simplifies the logic while using fewer variables and less arithmetic.
Note that the partial head is now cleaned using the unaligned start of the region instead of the start of its cacheline. This is permitted by the architecture; the Arm ARM (DDI 0487) states:
"When a DC instruction requires an address argument this takes the form of a 64-bit register that holds the VA argument. No alignment restrictions apply for this address."
The same applies on Arm32.
Also, switch the asm() in the loop to asm_inline, like the neighbouring
ones: the wrapper expands to a single instruction with a trailing semicolon, which GCC counts as two statements, overestimating the size of the function when deciding whether to inline it.
This is CVE-2026-102699, part of XSA-519.
xen/arch/arm/include/asm/page.h +20 -8
@@ -168,7 +168,7 @@ static inline size_t read_dcache_line_bytes(void)static inline int invalidate_dcache_va_range (const void *p,unsigned long size) {size_t cacheline_mask = dcache_line_bytes -1 ; -unsigned long idx =0 ; +unsigned long partial_head;if ( !size )return 0 ;
@@ -178,23 +178,35 @@ static inline int invalidate_dcache_va_range(const void *p, unsigned long size)dsb (sy);/* So the CPU issues all writes to the range */ -if ( (uintptr_t )p & cacheline_mask ) +/* +* A cacheline only partially covered by the region has to be cleaned as +* well as invalidated, so that data living outside of the region is not +* discarded. +*/ + partial_head = (uintptr_t )p & cacheline_mask; +if ( partial_head ) { - size -= dcache_line_bytes - ((uintptr_t )p & cacheline_mask); - p = (void *)((uintptr_t )p & ~cacheline_mask); +unsigned long rem = dcache_line_bytes - partial_head; +asm_inline volatile ( __clean_and_invalidate_dcache_one(0) :: "r" (p) ); - p += dcache_line_bytes; + p += rem; + +/* The region may end within this cacheline, leaving nothing to do. */ +if (__builtin_usubl_overflow (size, rem, &size) ) + goto done; }for ( ; size >= dcache_line_bytes; - idx += dcache_line_bytes, size -= dcache_line_bytes ) - asm volatile (__invalidate_dcache_one(0) : : "r" (p + idx)); + p += dcache_line_bytes, size -= dcache_line_bytes ) + asm_inline volatile (__invalidate_dcache_one(0) : : "r" (p)); +/* Partial tail must be cleaned as well. */ if ( size >0 ) asm_inline volatile ( - __clean_and_invalidate_dcache_one(0) :: "r" (p + idx) ); + __clean_and_invalidate_dcache_one(0) :: "r" (p) ); + done:dsb (sy);/* So we know the flushes happen before continuing */ return 0 ;
From: Andrew Cooper <[email protected]>
Subject: xen/gnttab: Prevent GNTTABOP_cache_flush from corrupting RO grants
Grants can be offered read-only by the owning domain. While a domain mapping a RO grant may have a need to invalidate the cache, it must not modify the other-guests data while doing so. Force-upgrade to a clean operation in this case.
This is CVE-2026-102702, part of XSA-519.
xen/common/grant_table.c +26 -1
@@ -983,6 +983,13 @@ static struct active_grant_entry *grant_map_exists(const struct domain *ld,return ERR_PTR (-EINVAL ); } + +static bool grant_map_is_ro (struct active_grant_entry *act) +{ +ASSERT (spin_is_locked (&act->lock)); + +return (act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) ==0 ; +}#endif /* CONFIG_HAS_GRANT_CACHE_FLUSH */ union maptrack_node {
@@ -3597,7 +3604,7 @@ gnttab_swap_grant_ref(XEN_GUEST_HANDLE_PARAM(gnttab_swap_grant_ref_t) uop, }#ifdef CONFIG_HAS_GRANT_CACHE_FLUSH -static int _cache_flush (const gnttab_cache_flush_t *cflush,grant_ref_t *cur_ref) +static int _cache_flush (gnttab_cache_flush_t *cflush,grant_ref_t *cur_ref) {struct domain *d, *owner;struct page_info *page;
@@ -3648,6 +3655,24 @@ static int _cache_flush(const gnttab_cache_flush_t *cflush, grant_ref_t *cur_refput_page (page);return act ?PTR_ERR (act) :1 ; } + +/* +* If the grant mapping is read-only, it must be cleaned as well as +* invalidated. Invalidation without cleaning may modify memory the +* granter is expecting not to change. +* +* It is highly unlikely but legal to have multiple grant mappings of +* differing read-only-ness. If a read-write grant mapping is found +* first, then it's fine to invalidate without clean. +* +* If a read-only grant mapping is found first, a later read-write +* mapping could be missed. Assume that the read-only mapping is the +* only mapping. The cost is a clean of up to 4k, while the saving is +* not requiring the search of grant maps to be exhaustive in order to +* spot a corner-case expected not to exist in practice. +*/ +if (grant_map_is_ro (act) ) + cflush->op |=GNTTAB_CACHE_CLEAN ; } v =map_domain_page (mfn);
From: Leonid Komarianskyi <[email protected]>
Subject: xen/arm: page: fix size underflow in invalidate_dcache_va_range()
When the start address is not cacheline aligned, the bytes covered by the first, partial cacheline are subtracted from 'size'. Nothing checks that the region actually extends beyond that cacheline, so if it does not, the unsigned subtraction underflows and the loop that follows walks practically the entire address space.
For example, with a 64-byte cacheline, p = 0x40000001 and size = 1:
p & cacheline_mask -> 1, so the partial head is taken
size -= 64 - 1 -> 1 - 63 underflows to 0xffffffffffffffc2Instead of a single "dc civac" at 0x40000000, the loop then runs 288230376151711743 times, issuing "dc ivac" from 0x40000040 upwards. Invalidating without cleaning discards dirty cachelines, so this corrupts whatever is mapped along the way until Xen takes a data abort.
Moreover, _cache_flush() in common/grant_table.c, reachable from a guest via GNTTABOP_cache_flush, bounds 'offset' and 'length' against the page size but requires no alignment, so GNTTAB_CACHE_INVAL with offset = 1 and length = 1 is enough to trigger this. Note that the page may belong to a different domain (the d != owner path), so the data being discarded is not necessarily the caller's own.
The subtraction dates back to the fix for XSA-437, so this is a regression in that change.
Fix this by detecting the underflow instead of letting it happen: if the region ends inside the first cacheline, there is nothing left to flush and the function bails out right after cleaning it. Partially covered cachelines are still cleaned as well as invalidated, so that data outside of the region is not discarded.
Additionally, drop 'idx' and advance 'p' directly instead. It simplifies the logic while using fewer variables and less arithmetic.
Note that the partial head is now cleaned using the unaligned start of the region instead of the start of its cacheline. This is permitted by the architecture; the Arm ARM (DDI 0487) states:
"When a DC instruction requires an address argument this takes the form of a 64-bit register that holds the VA argument. No alignment restrictions apply for this address."
The same applies on Arm32.
This is CVE-2026-102699, part of XSA-519.
xen/arch/arm/include/asm/page.h +21 -8
@@ -162,7 +162,7 @@ static inline size_t read_dcache_line_bytes(void)static inline int invalidate_dcache_va_range (const void *p,unsigned long size) {size_t cacheline_mask = dcache_line_bytes -1 ; -unsigned long idx =0 ; +unsigned long partial_head;if ( !size )return 0 ;
@@ -172,21 +172,34 @@ static inline int invalidate_dcache_va_range(const void *p, unsigned long size)dsb (sy);/* So the CPU issues all writes to the range */ -if ( (uintptr_t )p & cacheline_mask ) +/* +* A cacheline only partially covered by the region has to be cleaned as +* well as invalidated, so that data living outside of the region is not +* discarded. +*/ + partial_head = (uintptr_t )p & cacheline_mask; +if ( partial_head ) { - size -= dcache_line_bytes - ((uintptr_t )p & cacheline_mask); - p = (void *)((uintptr_t )p & ~cacheline_mask); +unsigned long rem = dcache_line_bytes - partial_head; + asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p)); - p += dcache_line_bytes; + p += rem; + +/* The region may end within this cacheline, leaving nothing to do. */ + size -= rem; +if ( size > rem )/* underflow */ + goto done; }for ( ; size >= dcache_line_bytes; - idx += dcache_line_bytes, size -= dcache_line_bytes ) - asm volatile (__invalidate_dcache_one(0) : : "r" (p + idx)); + p += dcache_line_bytes, size -= dcache_line_bytes ) + asm volatile (__invalidate_dcache_one(0) : : "r" (p)); +/* Partial tail must be cleaned as well. */ if ( size >0 ) - asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p + idx)); + asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p)); + done:dsb (sy);/* So we know the flushes happen before continuing */ return 0 ;
From: Andrew Cooper <[email protected]>
Subject: xen/gnttab: Prevent GNTTABOP_cache_flush from corrupting RO grants
Grants can be offered read-only by the owning domain. While a domain mapping a RO grant may have a need to invalidate the cache, it must not modify the other-guests data while doing so. Force-upgrade to a clean operation in this case.
This is CVE-2026-102702, part of XSA-519.
xen/common/grant_table.c +26 -1
@@ -983,6 +983,13 @@ static struct active_grant_entry *grant_map_exists(const struct domain *ld,return ERR_PTR (-EINVAL ); } +static bool grant_map_is_ro (struct active_grant_entry *act) +{ +ASSERT (spin_is_locked (&act->lock)); + +return (act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) ==0 ; +} +union maptrack_node {struct {/* Radix tree slot pointers use two of the bits. */
@@ -3595,7 +3602,7 @@ gnttab_swap_grant_ref(XEN_GUEST_HANDLE_PARAM(gnttab_swap_grant_ref_t) uop,return 0 ; } -static int _cache_flush (const gnttab_cache_flush_t *cflush,grant_ref_t *cur_ref) +static int _cache_flush (gnttab_cache_flush_t *cflush,grant_ref_t *cur_ref) {struct domain *d, *owner;struct page_info *page;
@@ -3646,6 +3653,24 @@ static int _cache_flush(const gnttab_cache_flush_t *cflush, grant_ref_t *cur_refput_page (page);return act ?PTR_ERR (act) :1 ; } + +/* +* If the grant mapping is read-only, it must be cleaned as well as +* invalidated. Invalidation without cleaning may modify memory the +* granter is expecting not to change. +* +* It is highly unlikely but legal to have multiple grant mappings of +* differing read-only-ness. If a read-write grant mapping is found +* first, then it's fine to invalidate without clean. +* +* If a read-only grant mapping is found first, a later read-write +* mapping could be missed. Assume that the read-only mapping is the +* only mapping. The cost is a clean of up to 4k, while the saving is +* not requiring the search of grant maps to be exhaustive in order to +* spot a corner-case expected not to exist in practice. +*/ +if (grant_map_is_ro (act) ) + cflush->op |=GNTTAB_CACHE_CLEAN ; } v =map_domain_page (mfn);