]> xenbits.xensource.com Git - xen.git/commitdiff
gnttab: check handle early in gnttab_get_status_frames()
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Sep 2021 07:36:20 +0000 (09:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Sep 2021 07:36:20 +0000 (09:36 +0200)
Like done in gnttab_setup_table(), check the handle once early in the
function and use the lighter-weight (for PV) copying function in the
loop.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/common/grant_table.c

index 2d6f38cd8cc56b6220d92f8da8acf4b407408c6a..da687acc61710c4dbfc5dc9c69677c506626db5f 100644 (file)
@@ -3229,6 +3229,9 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop,
         return -EFAULT;
     }
 
+    if ( !guest_handle_okay(op.frame_list, op.nr_frames) )
+        return -EFAULT;
+
     d = rcu_lock_domain_by_any_id(op.dom);
     if ( d == NULL )
     {
@@ -3269,7 +3272,7 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop,
     for ( i = 0; i < op.nr_frames; i++ )
     {
         gmfn = gfn_x(gnttab_status_gfn(d, gt, i));
-        if ( copy_to_guest_offset(op.frame_list, i, &gmfn, 1) )
+        if ( __copy_to_guest_offset(op.frame_list, i, &gmfn, 1) )
             op.status = GNTST_bad_virt_addr;
     }