[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.20] xen/domain: Disallow XENMEM_claim_pages on dying domains



commit 95c476191fbb654cf62571b4e59da77ba9289bff
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Jan 29 13:43:29 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jan 29 13:43:29 2026 +0100

    xen/domain: Disallow XENMEM_claim_pages on dying domains
    
    XENMEM_claim_pages can be issued on a domain in the later stages of
    domain_kill().  In that case, the claimed memory is leaked, as there's no 
way
    to subsequently release the claim.
    
    Claims are intended for use during domain construction; to reserve 
sufficient
    RAM to construct the domain fully.  There's no legitimate reason to be 
calling
    it on a dying domain.
    
    Fixes: 65c9792df600 ("mmu: Introduce XENMEM_claim_pages (subop of memory 
ops)")
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    master commit: 2379ca04feab7df40051d03f73487d9e0cef43ac
    master date: 2025-12-17 17:35:24 +0000
---
 xen/common/memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 1165ef200f..c78f0dcd0a 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1683,6 +1683,9 @@ long do_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 
         rc = xsm_claim_pages(XSM_PRIV, d);
 
+        if ( !rc && d->is_dying )
+            rc = -EINVAL;
+
         if ( !rc )
             rc = domain_set_outstanding_pages(d, reservation.nr_extents);
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.20



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.