|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging-4.17] xen/mm: reorder page vs gfn release order in guest_remove_page()
commit ffab57e0ea1af6677527d6e7463f376da9499fab
Author: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
AuthorDate: Thu Nov 26 18:01:22 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 26 18:01:22 2026 +0100
xen/mm: reorder page vs gfn release order in guest_remove_page()
The current order of put_page() and put_gfn() calls can lead to the removed
page being freed before performing a p2m TLB flush, if the caller of
guest_remove_page() doesn't hold a reference to the page being unhooked
from the p2m.
Invert the call order, so that the p2m is unlocked first, possibly carrying
any deferred flushes, and the page is released afterwards. This fixes the
usage of guest_remove_page() in decrease_reservation(), that would
otherwise free the pages before the p2m flush.
Note there are calls to guest_remove_page() with the p2m lock already held;
those are dealt with in separate changes.
This is XSA-535 / CVE-2026-119781
Fixes: 09fc40ed3054 ("x86/ept: defer the invalidation until the p2m lock is
released")
Fixes: e1604ea82700 ("x86/hap: Defer NPT P2M TLB flushes")
Signed-off-by: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
master commit: 6019959aecb1a78227c8773d7b0dccdc74a9f28b
master date: 2026-11-26 17:26:00 +0100
---
xen/common/memory.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/xen/common/memory.c b/xen/common/memory.c
index e5983997f0..2768929ce3 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -292,7 +292,7 @@ out:
int guest_remove_page(struct domain *d, unsigned long gmfn)
{
- struct page_info *page;
+ struct page_info *page = NULL;
#ifdef CONFIG_X86
p2m_type_t p2mt;
#endif
@@ -413,13 +413,19 @@ int guest_remove_page(struct domain *d, unsigned long
gmfn)
if ( !rc && !is_domain_direct_mapped(d) )
put_page_alloc_ref(page);
- put_page(page);
-
#ifdef CONFIG_X86
out_put_gfn:
put_gfn(d, gmfn);
#endif
+ /*
+ * Do the final put page after the p2m flush possibly done when putting the
+ * gfn. Otherwise we risk freeing the page while there are stale p2m TLB
+ * entries.
+ */
+ if ( page )
+ put_page(page);
+
/*
* Filter out -ENOENT return values that aren't a result of an empty p2m
* entry.
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |