[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xen: Fix failure paths for xentrace



# HG changeset patch
# User George Dunlap <george.dunlap@xxxxxxxxxxxxx>
# Date 1334235687 -3600
# Node ID c6bde42c8845439183336602a78bc07869f3651b
# Parent  6efb9f934bfb4c46af375612fb01e65d15518380
xen: Fix failure paths for xentrace

Problems this addresses:
* After the allocation of t_info fails, the path the code takes tries
to free t_info.  Jump past that part instead.
* The failure code assumes that unused data is zero; but the structure
is never initialized.  Zero the structure before using it.
* The t_info pages are shared with dom0 before we know that the whole
operation will succeed, and not un-shared afterwards.  Don't share the
pages until we know the whole thing will succeed.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 6efb9f934bfb -r c6bde42c8845 xen/common/trace.c
--- a/xen/common/trace.c        Thu Apr 05 11:24:26 2012 +0100
+++ b/xen/common/trace.c        Thu Apr 12 14:01:27 2012 +0100
@@ -187,14 +187,12 @@ static int alloc_trace_bufs(unsigned int
 
     t_info = alloc_xenheap_pages(get_order_from_pages(t_info_pages), 0);
     if ( t_info == NULL )
-        goto out_dealloc_t_info;
+        goto out_fail;
+
+    memset(t_info, 0, t_info_pages*PAGE_SIZE);
 
     t_info_mfn_list = (uint32_t *)t_info;
 
-    for(i = 0; i < t_info_pages; i++)
-        share_xen_page_with_privileged_guests(
-            virt_to_page(t_info) + i, XENSHARE_readonly);
-
     t_info->tbuf_size = pages;
 
     /*
@@ -247,6 +245,11 @@ static int alloc_trace_bufs(unsigned int
         }
     }
 
+    /* Finally, share the t_info page */
+    for(i = 0; i < t_info_pages; i++)
+        share_xen_page_with_privileged_guests(
+            virt_to_page(t_info) + i, XENSHARE_readonly);
+
     data_size  = (pages * PAGE_SIZE - sizeof(struct t_buf));
     t_buf_highwater = data_size >> 1; /* 50% high water */
     opt_tbuf_size = pages;
@@ -272,9 +275,9 @@ out_dealloc:
             free_xenheap_pages(mfn_to_virt(mfn), 0);
         }
     }
-out_dealloc_t_info:
     free_xenheap_pages(t_info, get_order_from_pages(t_info_pages));
     t_info = NULL;
+out_fail:
     printk(XENLOG_WARNING "xentrace: allocation failed! Tracing disabled.\n");
     return -ENOMEM;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.