]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/mm: Put the gfn on all paths after get_gfn_query()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 20 Nov 2018 14:32:34 +0000 (15:32 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Nov 2018 14:32:34 +0000 (15:32 +0100)
c/s 7867181b2 "x86/PoD: correctly handle non-order-0 decrease-reservation
requests" introduced an early exit in guest_remove_page() for unexpected p2m
types.  However, get_gfn_query() internally takes the p2m lock, and must be
matched with a put_gfn() call later.

Fix the erroneous comment beside the declaration of get_gfn_query().

This is XSA-277.

Reported-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: d80988cfc04ee608bee722448e7c3bc8347ec04c
master date: 2018-11-20 14:58:10 +0100

xen/common/memory.c
xen/include/asm-x86/p2m.h

index 75010b78a5aee7ced8ab0655b54ae5d0e4be0723..4fb7962c7941e34a0e4f9417b440e0d9ce1858e1 100644 (file)
@@ -303,7 +303,11 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
 #ifdef CONFIG_X86
     mfn = get_gfn_query(d, gmfn, &p2mt);
     if ( unlikely(p2mt == p2m_invalid) || unlikely(p2mt == p2m_mmio_dm) )
+    {
+        put_gfn(d, gmfn);
+
         return -ENOENT;
+    }
 
     if ( unlikely(p2m_is_paging(p2mt)) )
     {
index d4b3cfcb6ead9062c4d7dd19c6ef54be6017a5b4..3f41deaeea64124579ee0baa265353b43e128a09 100644 (file)
@@ -432,10 +432,7 @@ static inline mfn_t __nonnull(3) get_gfn_type(
     return get_gfn_type_access(p2m_get_hostp2m(d), gfn, t, &a, q, NULL);
 }
 
-/* Syntactic sugar: most callers will use one of these. 
- * N.B. get_gfn_query() is the _only_ one guaranteed not to take the
- * p2m lock; none of the others can be called with the p2m or paging
- * lock held. */
+/* Syntactic sugar: most callers will use one of these. */
 #define get_gfn(d, g, t)         get_gfn_type((d), (g), (t), P2M_ALLOC)
 #define get_gfn_query(d, g, t)   get_gfn_type((d), (g), (t), 0)
 #define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), \