]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
gnttab: bail from GFN-storing loops early in case of error
authorJan Beulich <jbeulich@suse.com>
Fri, 2 Dec 2022 09:25:59 +0000 (10:25 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 2 Dec 2022 09:25:59 +0000 (10:25 +0100)
The contents of the output arrays are undefined anyway when the
operation itself gets marked as failed. There's no value in trying to
continue after a guest memory access failure.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/compat/grant_table.c
xen/common/grant_table.c

index 4f6d0b05fbedd2f519f0ee57dff53614f68da344..744f9b6e3d2ba9ddd008beb59103249688e1bec6 100644 (file)
@@ -179,7 +179,10 @@ int compat_grant_table_op(
                             unsigned int frame = (_s_)->frame_list.p[i]; \
                             if ( __copy_to_compat_offset((_d_)->frame_list, \
                                                          i, &frame, 1) ) \
+                            { \
                                 (_s_)->status = GNTST_bad_virt_addr; \
+                                break; \
+                            } \
                         } \
                     } \
                 } while (0)
index 6326bae5aa725e58cd31d341d5cedf41dadafc0b..fa28c3cb7b7663083377db19acf0dd945b36b89a 100644 (file)
@@ -2101,7 +2101,10 @@ gnttab_setup_table(
         BUG_ON(SHARED_M2P(gmfn));
 
         if ( __copy_to_guest_offset(op.frame_list, i, &gmfn, 1) )
+        {
             op.status = GNTST_bad_virt_addr;
+            break;
+        }
     }
 
  unlock:
@@ -3311,7 +3314,10 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop,
     {
         gmfn = gfn_x(gnttab_status_gfn(d, gt, i));
         if ( __copy_to_guest_offset(op.frame_list, i, &gmfn, 1) )
+        {
             op.status = GNTST_bad_virt_addr;
+            break;
+        }
     }
 
  unlock: