Skip to contentSkip to conversation

libxc: Fix Segmentation fault of xend

PATCH NAK Yu Zhiguo 3 participants 7 messages Jun 19, 2010 – Jun 22, 2010 Arm/actions semi architecture

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

PATCH 1/1 libxc: Fix Segmentation fault of xend

If /proc/xen/privcmd cannot be opened,
start xend occurs Segmentation fault.
Add check to fix it.

tools/libxc/xc_private.c +4 -2
diff -r b9c541d9c138 -r 659e4b69d26b tools/libxc/xc_private.c
@@ -82,8 +82,10 @@
 
 void xc_clear_last_error(xc_interface *xch)
 {
-    xch->last_error.code = XC_ERROR_NONE;
-    xch->last_error.message[0] = '\0';
+    if (xch) {
+        xch->last_error.code = XC_ERROR_NONE;
+        xch->last_error.message[0] = '\0';
+    }
 }
 
 const char *xc_error_code_to_desc(int code)
Nacked-by on v1 1/1 NAK
#1 lore raw

Yu Zhiguo writes ("[Xen-devel] [PATCH] libxc: Fix Segmentation fault of xend"):

Quoted 3 lines

If /proc/xen/privcmd cannot be opened,
start xend occurs Segmentation fault.
Add check to fix it.

This change is not correct.

Quoted 1 line

void xc_clear_last_error(xc_interface *xch)

...

tools/libxc/xc_private.c line 85

Quoted 2 lines
tools/libxc/xc_private.c +1 -1
-    xch->last_error.message[0] = '\0';
+    if (xch) {

It is wrong to call xc_clear_last_error with a NULL xc_interface*. If xend is doing this it is probably a bug in the python xc lowlevel interface. Can you get a stack trace please so that we can fix the call site ?

Ian.

#4 lore raw

Keir Fraser writes ("Re: [Xen-devel] [PATCH] libxc: Fix Segmentation fault of xend"):

Quoted 7 lines · Ian Jackson
Quoted 4 lines
Quoted 1 line · I wrote:

I see that, unfortunately, this patch has already been applied.

I can revert it.

Thanks, I think that would be best.

Ian.

author
#5 lore raw

Re: [PATCH] lowlevel: Fix Segmentation fault of xend

In reply to Ian Jackson

Hi Ian,

Quoted 6 lines · Ian Jackson

It is wrong to call xc_clear_last_error with a NULL xc_interface*. If xend is doing this it is probably a bug in the python xc lowlevel interface. Can you get a stack trace please so that we can fix the call site ?

The stack trace is
PyXc_init()
-> pyxc_error_to_exception(0)
-> xc_clear_last_error()

So fix it in pyxc_error_to_exception(). Thanks for your reply.

V2 is following.

-----------------

If /proc/xen/privcmd cannot be opened,
start xend occurs Segmentation fault.
Add check to fix it.

tools/python/xen/lowlevel/xc/xc.c +2 -1
diff -r 72c6228b5f0f -r bd3bf925f4ce tools/python/xen/lowlevel/xc/xc.c
@@ -72,7 +72,8 @@
     else
         pyerr = Py_BuildValue("(is)", err->code, desc);
 
-    xc_clear_last_error(xch);
+    if (xch)
+        xc_clear_last_error(xch);
 
     if ( pyerr != NULL )
     {
#6 lore raw

Re: [PATCH] lowlevel: Fix Segmentation fault of xend

Yu Zhiguo writes ("Re: [Xen-devel] [PATCH] lowlevel: Fix Segmentation fault of xend"):

Quoted 6 lines

The stack trace is
PyXc_init()
-> pyxc_error_to_exception(0)
-> xc_clear_last_error()

So fix it in pyxc_error_to_exception(). Thanks for your reply.

That's great, thanks.

Ian.