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

[xen stable-4.13] xen/memory: Don't skip the RCU unlock path in acquire_resource()



commit 286b3539b7e6af63c22c080c4dfe52c957e0c23f
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Sep 22 16:20:46 2020 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Sep 22 16:20:46 2020 +0200

    xen/memory: Don't skip the RCU unlock path in acquire_resource()
    
    In the case that an HVM Stubdomain makes an XENMEM_acquire_resource 
hypercall,
    the FIXME path will bypass rcu_unlock_domain() on the way out of the 
function.
    
    Move the check to the start of the function.  This does change the behaviour
    of the get-size path for HVM Stubdomains, but that functionality is 
currently
    broken and unused anyway, as well as being quite useless to entities which
    can't actually map the resource anyway.
    
    This is XSA-334.
    
    Fixes: 83fa6552ce ("common: add a new mappable resource type: 
XENMEM_resource_grant_table")
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/memory.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 3c085a0cd0..b2b6a775d9 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1057,6 +1057,14 @@ static int acquire_resource(
     xen_pfn_t mfn_list[32];
     int rc;
 
+    /*
+     * FIXME: Until foreign pages inserted into the P2M are properly
+     *        reference counted, it is unsafe to allow mapping of
+     *        resource pages unless the caller is the hardware domain.
+     */
+    if ( paging_mode_translate(currd) && !is_hardware_domain(currd) )
+        return -EACCES;
+
     if ( copy_from_guest(&xmar, arg, 1) )
         return -EFAULT;
 
@@ -1113,14 +1121,6 @@ static int acquire_resource(
         xen_pfn_t gfn_list[ARRAY_SIZE(mfn_list)];
         unsigned int i;
 
-        /*
-         * FIXME: Until foreign pages inserted into the P2M are properly
-         *        reference counted, it is unsafe to allow mapping of
-         *        resource pages unless the caller is the hardware domain.
-         */
-        if ( !is_hardware_domain(currd) )
-            return -EACCES;
-
         if ( copy_from_guest(gfn_list, xmar.frame_list, xmar.nr_frames) )
             rc = -EFAULT;
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.13



 


Rackspace

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