WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] do_memory_op: cleanup if copy_to_guest fails

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] do_memory_op: cleanup if copy_to_guest fails
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Thu, 16 Dec 2010 18:59:10 +0100
Delivery-date: Thu, 16 Dec 2010 10:02:08 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1292522351; l=1066; s=domk; d=aepfle.de; h=Content-Type:MIME-Version:Subject:To:From:Date:X-RZG-CLASS-ID: X-RZG-AUTH; bh=Iwnw9O2ulSq6Iv/zmoSdVD0ukV4=; b=ynbtqtCIW9amPfdwrqBnLc9EARwijPRiGXyN8huEyV7z2XRh8vQILd7XGHdcxigWmnV 7Fb1nHxhIu43sZ7tkZWpxkGLb6vs9WZMjJ6gd7WbUzyjyycCl/I55uTIjhRcod37fKPYX qX7ZEpe4JUsy2/l6XRnV3sqYck2eksgtrRI=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
Undo the page allocation in the ulikely event the copy_to_guest fails.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

---

I have not exercised this code path, it was found during code inspection in 4.0

 xen/common/memory.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- xen-unstable.hg-4.1.22548.orig/xen/common/memory.c
+++ xen-unstable.hg-4.1.22548/xen/common/memory.c
@@ -82,7 +82,10 @@ static void increase_reservation(struct
         {
             mfn = page_to_mfn(page);
             if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn, 1)) )
+            {
+                free_domheap_pages(page, a->extent_order);
                 goto out;
+            }
         }
     }
 
@@ -144,7 +147,13 @@ static void populate_physmap(struct memo
 
                 /* Inform the domain of the new page's machine address. */ 
                 if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn, 
1)) )
+                {
+                    for ( j = 0; j < (1 << a->extent_order); j++ )
+                        set_gpfn_from_mfn(mfn + j, INVALID_M2P_ENTRY);
+                    guest_physmap_remove_page(d, gpfn, mfn, a->extent_order);
+                    free_domheap_pages(page, a->extent_order);
                     goto out;
+                }
             }
         }
     }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>