Skip to contentSkip to conversation

libxc: fix segfault on uninitialized xch->fmem

PATCH Applied Seraphime Kirkovski 3 participants 4 messages Apr 4, 2017 – Apr 5, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libxc: fix segfault on uninitialized xch->fmem

Currently in xc_interface_open, xch->fmem is not initialized and in some rare case the code fails before ever assigning a value to it.

I got this in master:

   $ sudo ./xl/xl run
   xencall: error: Could not obtain handle on privileged command interface: No such file or directory
   Segmentation fault

This initializes the whole xch_buff to 0.

---

Changes from v1:
* Initialize the entire struct xc_interface_core to 0

 tools/libxc/xc_private.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_private.c +1 -1
index 72e6242417..f395594a8f 100644
@@ -30,7 +30,7 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
                                             xentoollog_logger *dombuild_logger,
                                             unsigned open_flags)
 {
-    struct xc_interface_core xch_buf, *xch = &xch_buf;
+    struct xc_interface_core xch_buf = { 0 }, *xch = &xch_buf;
 
     xch->flags = open_flags;
     xch->dombuild_logger_file = 0;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines · Seraphime Kirkovski

Currently in xc_interface_open, xch->fmem is not initialized and in some rare case the code fails before ever assigning a value to it.

I got this in master:

Quoted 7 lines
   $ sudo ./xl/xl run
   xencall: error: Could not obtain handle on privileged command interface: No such file or directory
   Segmentation fault

This initializes the whole xch_buff to 0.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 11 lines · Wei Liu
Quoted 10 lines · Seraphime Kirkovski

Currently in xc_interface_open, xch->fmem is not initialized and in some rare case the code fails before ever assigning a value to it.

I got this in master:

   $ sudo ./xl/xl run
   xencall: error: Could not obtain handle on privileged command interface: No such file or directory
   Segmentation fault
Quoted 5 lines
Quoted 3 lines

This initializes the whole xch_buff to 0.

Ian, this is a backport candidate.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Applied
#3 lore raw

Wei Liu writes ("Re: [PATCHv2] libxc: fix segfault on uninitialized xch->fmem"):

Quoted 1 line

Ian, this is a backport candidate.

Queued, thanks (until after 4.8.1, given that currently this is in staging only).

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel