Skip to contentSkip to conversation

fix mfn check of gnttab_transfer()

PATCH In review Isaku Yamahata 3 participants 3 messages Apr 4, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix mfn check of gnttab_transfer()

fix mfn check of gnttab_transfer().

Signature · 1 line
yamahata

# HG changeset patch
# User [email protected]
# Node ID 30e807eee6f168b7a9e12e67b36cc669cbdadcf5 # Parent d0d3fef37685be264a7f52201f8ef44c030daad3 fix mfn check of gnttab_transfer. gop.mfn is gmfn.

xen/common/grant_table.c +3 -2
diff -r d0d3fef37685 -r 30e807eee6f1 xen/common/grant_table.c
@@ -618,8 +618,9 @@ gnttab_transfer(
             return -EFAULT;
         }
 
+        mfn = gmfn_to_mfn(d, gop.mfn);
         /* Check the passed page frame for basic validity. */
-        if ( unlikely(!mfn_valid(gop.mfn)) )
+        if ( unlikely(mfn == INVALID_MFN) || unlikely(!mfn_valid(mfn)) )
         { 
             DPRINTK("gnttab_transfer: out-of-range %lx\n",
                     (unsigned long)gop.mfn);
@@ -627,7 +628,6 @@ gnttab_transfer(
             goto copyback;
         }
 
-        mfn = gmfn_to_mfn(d, gop.mfn);
         page = mfn_to_page(mfn);
         if ( unlikely(IS_XEN_HEAP_FRAME(page)) )
         { 
@@ -639,6 +639,7 @@ gnttab_transfer(
 
         if ( steal_page_for_grant_transfer(d, page) < 0 )
         {
+            DPRINTK("steal_page_for_grant_transfer\n");
             gop.status = GNTST_bad_page;
             goto copyback;
         }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 1 line · Isaku Yamahata

fix mfn check of gnttab_transfer().

What's wrong with the mfn check? mfn_valid() will return false for INVALID_MFN so there's no need to check for it explicitly.

-- Keir

#2 lore raw
Quoted 3 lines
Quoted 1 line

fix mfn check of gnttab_transfer().

What's wrong with the mfn check? mfn_valid() will return false for INVALID_MFN so there's no need to check for it explicitly.

The interesting part here is that the mfn_valid() should be called on the mfn rather than the gmfn, and I've applied that part.

Steven.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel