libxl: don't segfault when creating domain with invalid pvusb device
PATCH 1/1 libxl: don't segfault when creating domain with invalid pvusb device
Creating a domain with an invalid controller specification for a pvusb device will currently segfault.
Avoid this by bailing out early in case of a mandatory xenstore path not existing.
---
This patch is a backport candidate for 4.8
--- tools/libxl/libxl_usb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
tools/libxl/libxl_usb.c +7 -6
@@ -651,12 +651,13 @@ int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid, usbctrlinfo->devid = usbctrl->devid; -#define READ_SUBPATH (path, subpath) ({ \ - rc = libxl__xs_read_checked(gc, XBT_NULL, \ - GCSPRINTF("%s/" subpath, path), \ - &tmp); \ - if (rc) goto out; \ - (char *)tmp; \ +#define READ_SUBPATH (path, subpath) ({ \ + tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/" subpath, path)); \ + if (!tmp) { \ + rc = ERROR_FAIL; \ + goto out; \ + } \ + (char *)tmp; \ })#define READ_SUBPATH_INT (path, subpath) ({ \
Signature · 7 lines
2.10.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross writes ("[PATCH] libxl: don't segfault when creating domain with invalid pvusb device"):
Quoted 5 lines
Creating a domain with an invalid controller specification for a pvusb device will currently segfault.
Avoid this by bailing out early in case of a mandatory xenstore path not existing.
This should be done by adding a test of tmp for NULL. libxl__xs_read does no logging so is not really an improvement.
If you felt like inventing libxl__xs_read_must or something (maybe Wei has a suggestion for a better name) that calls ENOENT a failure instead, I'd be happy with that.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Ian Jackson
Juergen Gross writes ("[PATCH] libxl: don't segfault when creating domain with invalid pvusb device"):
Quoted 5 lines
Creating a domain with an invalid controller specification for a pvusb device will currently segfault.
Avoid this by bailing out early in case of a mandatory xenstore path not existing.
Quoted 6 lines
This should be done by adding a test of tmp for NULL.
libxl__xs_readdoes no logging so is not really an improvement.If you felt like inventing
libxl__xs_read_mustor something (maybe Wei has a suggestion for a better name) that calls ENOENT a failure instead, I'd be happy with that.
Okay. I think I'll name it libxl__xs_read_mandatory().
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel