gnttab: correct pin status fixup for copy
authorJan Beulich <jbeulich@suse.com>
Thu, 7 Sep 2017 17:18:50 +0000 (18:18 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Sep 2017 18:17:58 +0000 (19:17 +0100)
Regardless of copy operations only setting GNTPIN_hst*, GNTPIN_dev*
also need to be taken into account when deciding whether to clear
_GTF_{read,writ}ing. At least for consistency with code elsewhere the
read part better doesn't use any mask at all.

This is XSA-230.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Gbp-Pq: Name gnttab-correct-pin-status-fixup-for-copy

xen/common/grant_table.c

index 0a01515e39182807dc628f0794a78bf0d51e6962..141eb0843c014ec3ea128b810de5d3b35b06078c 100644 (file)
@@ -2110,10 +2110,10 @@ __release_grant_for_copy(
 static void __fixup_status_for_copy_pin(const struct active_grant_entry *act,
                                    uint16_t *status)
 {
-    if ( !(act->pin & GNTPIN_hstw_mask) )
+    if ( !(act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) )
         gnttab_clear_flag(_GTF_writing, status);
 
-    if ( !(act->pin & GNTPIN_hstr_mask) )
+    if ( !act->pin )
         gnttab_clear_flag(_GTF_reading, status);
 }
 
@@ -2348,7 +2348,7 @@ __acquire_grant_for_copy(
  
  unlock_out_clear:
     if ( !(readonly) &&
-         !(act->pin & GNTPIN_hstw_mask) )
+         !(act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) )
         gnttab_clear_flag(_GTF_writing, status);
 
     if ( !act->pin )