Skip to contentSkip to conversation

tools/xenctx: Correct use of xc_domain_{, un}pause()

PATCH Applied Andrew Cooper 2 participants 3 messages Jul 4, 2014 – Jul 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xenctx: Correct use of xc_domain_{, un}pause()

The previous code never worked correctly. There was a TOCTOU race between checking dominfo and pausing the domain.

Since c/s 3eb1c708, Xen properly reference counts pause hypercalls, so unconditionally pause and unpause the domain.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>
---
 tools/xentrace/xenctx.c |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
tools/xentrace/xenctx.c +8 -14
index 82bd789..4ed120a 100644
@@ -91,7 +91,6 @@ static struct xenctx {
     int do_stack;
 #endif
     int kernel_start_set;
-    int self_paused;
     xc_dominfo_t dominfo;
 } xenctx;
 
@@ -1273,13 +1272,10 @@ int main(int argc, char **argv)
         exit(-1);
     }
 
-    if (!xenctx.dominfo.paused) {
-        ret = xc_domain_pause(xenctx.xc_handle, xenctx.domid);
-        if (ret < 0) {
-            perror("xc_domain_pause");
-            exit(-1);
-        }
-        xenctx.self_paused = 1;
+    ret = xc_domain_pause(xenctx.xc_handle, xenctx.domid);
+    if (ret < 0) {
+        perror("xc_domain_pause");
+        exit(-1);
     }
 
 #ifndef NO_TRANSLATION
@@ -1303,12 +1299,10 @@ int main(int argc, char **argv)
     if ( do_default )
         dump_ctx(vcpu);
 
-    if (xenctx.self_paused) {
-        ret = xc_domain_unpause(xenctx.xc_handle, xenctx.domid);
-        if (ret < 0) {
-            perror("xc_domain_unpause");
-            exit(-1);
-        }
+    ret = xc_domain_unpause(xenctx.xc_handle, xenctx.domid);
+    if (ret < 0) {
+        perror("xc_domain_unpause");
+        exit(-1);
     }
 
     ret = xc_interface_close(xenctx.xc_handle);
Signature · 1 line
1.7.10.4
Applied
#2 lore raw
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Andrew Cooper

The previous code never worked correctly. There was a TOCTOU race between checking dominfo and pausing the domain.

Since c/s 3eb1c708, Xen properly reference counts pause hypercalls, so unconditionally pause and unpause the domain.

Applied.