Skip to contentSkip to conversation

libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument

PATCH In review Daniel Kiper 2 participants 4 messages Dec 2, 2013 – Dec 4, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxenctrl: Fix xc_interface_close() crash if it gets NULL as an argument

xc_interface_close() crashes if it gets NULL as an argument. However, it just calls xc_interface_close_common() which is called by many others functions. It means that they are also vulnerable. So fix above mentioned issue by adding NULL check in xc_interface_close_common(). This way we fix similar issue in other functions which calls xc_interface_close_common() too.

---
 tools/libxc/xc_private.c |    3 +++
 1 file changed, 3 insertions(+)
tools/libxc/xc_private.c +3 -0
index 524862e..838fd21 100644
@@ -198,6 +198,9 @@ static int xc_interface_close_common(xc_interface *xch)
 {
     int rc = 0;
 
+    if (!xch)
+	return 0;
+
     xc__hypercall_buffer_cache_release(xch);
 
     xtl_logger_destroy(xch->dombuild_logger_tofree);
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Daniel Kiper

xc_interface_close() crashes if it gets NULL as an argument. However, it just calls xc_interface_close_common() which is called by many others functions. It means that they are also vulnerable. So fix above mentioned issue by adding NULL check in xc_interface_close_common(). This way we fix similar issue in other functions which calls xc_interface_close_common() too.

I suppose this makes sense in the same way that free(NULL) does:

Did you observe this with a particular caller?

#2 lore raw
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Daniel Kiper

xc_interface_close() crashes if it gets NULL as an argument. However, it just calls xc_interface_close_common() which is called by many others functions. It means that they are also vulnerable. So fix above mentioned issue by adding NULL check in xc_interface_close_common(). This way we fix similar issue in other functions which calls xc_interface_close_common() too.

Quoted 4 lines
Quoted 1 line

I suppose this makes sense in the same way that free(NULL) does:

Thanks.

Quoted 1 line

Did you observe this with a particular caller?

Yes, I found this issue by chance in kaxec-tools. It is fixed right now but I agree that this type of functions should behave with NULL like free(NULL).

Daniel

#3 lore raw
Quoted 9 lines · Daniel Kiper
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Daniel Kiper

xc_interface_close() crashes if it gets NULL as an argument. However, it just calls xc_interface_close_common() which is called by many others functions. It means that they are also vulnerable. So fix above mentioned issue by adding NULL check in xc_interface_close_common(). This way we fix similar issue in other functions which calls xc_interface_close_common() too.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I suppose this makes sense in the same way that free(NULL) does:

Thanks.

And now applied.

Quoted 3 lines
Quoted 1 line

Did you observe this with a particular caller?

Yes, I found this issue by chance in kaxec-tools. It is fixed

Great, thanks.

Quoted 4 lines

right now but I agree that this type of functions should behave with NULL like free(NULL).

Daniel