]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
gnttab: fix GNTTABOP_copy continuation handling
authorJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 12:42:32 +0000 (14:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 12:42:32 +0000 (14:42 +0200)
The XSA-226 fix was flawed - the backwards transformation on rc was done
too early, causing a continuation to not get invoked when the need for
preemption was determined at the very first iteration of the request.
This in particular means that all of the status fields of the individual
operations would be left untouched, i.e. set to whatever the caller may
or may not have initialized them to.

This is part of XSA-318.

Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Tested-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
xen/common/grant_table.c

index 4b5344dc21f57e44427d9b7ae9882c1ad10aaa6f..96080b3dec28cbd50cdaddbd0dc4b4a21a93443b 100644 (file)
@@ -3576,8 +3576,7 @@ do_grant_table_op(
         rc = gnttab_copy(copy, count);
         if ( rc > 0 )
         {
-            rc = count - rc;
-            guest_handle_add_offset(copy, rc);
+            guest_handle_add_offset(copy, count - rc);
             uop = guest_handle_cast(copy, void);
         }
         break;
@@ -3644,6 +3643,9 @@ do_grant_table_op(
   out:
     if ( rc > 0 || opaque_out != 0 )
     {
+        /* Adjust rc, see gnttab_copy() for why this is needed. */
+        if ( cmd == GNTTABOP_copy )
+            rc = count - rc;
         ASSERT(rc < count);
         ASSERT((opaque_out & GNTTABOP_CMD_MASK) == 0);
         rc = hypercall_create_continuation(__HYPERVISOR_grant_table_op, "ihi",