|
|
c3a4ccc |
From 11770db72bc644c322ad9044dbf86f9c6cb3a780 Mon Sep 17 00:00:00 2001
|
|
|
c3a4ccc |
From: Ian Jackson <ian.jackson@eu.citrix.com>
|
|
|
c3a4ccc |
Date: Fri, 29 Apr 2016 19:21:51 +0100
|
|
|
c3a4ccc |
Subject: [PATCH 06/12] libxl: Do not trust frontend for disk in getinfo
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
* Rename the frontend variable to `fe_path' to check we caught them all
|
|
|
c3a4ccc |
* Read the backend path from /libxl, rather than from the frontend
|
|
|
c3a4ccc |
* Parse the backend domid from the backend path, rather than reading it
|
|
|
c3a4ccc |
from the frontend (and add the appropriate error path and initialisation)
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
This is part of XSA-175.
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
|
|
|
c3a4ccc |
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
|
|
|
c3a4ccc |
---
|
|
|
c3a4ccc |
tools/libxl/libxl.c | 27 +++++++++++++++++++--------
|
|
|
c3a4ccc |
1 file changed, 19 insertions(+), 8 deletions(-)
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
|
|
|
c3a4ccc |
index 9c0fed4..69b7da7 100644
|
|
|
c3a4ccc |
--- a/tools/libxl/libxl.c
|
|
|
c3a4ccc |
+++ b/tools/libxl/libxl.c
|
|
|
c3a4ccc |
@@ -2796,27 +2796,34 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
|
|
|
c3a4ccc |
libxl_device_disk *disk, libxl_diskinfo *diskinfo)
|
|
|
c3a4ccc |
{
|
|
|
c3a4ccc |
GC_INIT(ctx);
|
|
|
c3a4ccc |
- char *dompath, *diskpath;
|
|
|
c3a4ccc |
+ char *dompath, *fe_path, *libxl_path;
|
|
|
c3a4ccc |
char *val;
|
|
|
c3a4ccc |
+ int rc;
|
|
|
c3a4ccc |
+
|
|
|
c3a4ccc |
+ diskinfo->backend = NULL;
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
dompath = libxl__xs_get_dompath(gc, domid);
|
|
|
c3a4ccc |
diskinfo->devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
/* tap devices entries in xenstore are written as vbd devices. */
|
|
|
c3a4ccc |
- diskpath = libxl__sprintf(gc, "%s/device/vbd/%d", dompath, diskinfo->devid);
|
|
|
c3a4ccc |
+ fe_path = GCSPRINTF("%s/device/vbd/%d", dompath, diskinfo->devid);
|
|
|
c3a4ccc |
+ libxl_path = GCSPRINTF("%s/device/vbd/%d",
|
|
|
c3a4ccc |
+ libxl__xs_libxl_path(gc, domid), diskinfo->devid);
|
|
|
c3a4ccc |
diskinfo->backend = xs_read(ctx->xsh, XBT_NULL,
|
|
|
c3a4ccc |
- libxl__sprintf(gc, "%s/backend", diskpath), NULL);
|
|
|
c3a4ccc |
+ GCSPRINTF("%s/backend", libxl_path), NULL);
|
|
|
c3a4ccc |
if (!diskinfo->backend) {
|
|
|
c3a4ccc |
GC_FREE;
|
|
|
c3a4ccc |
return ERROR_FAIL;
|
|
|
c3a4ccc |
}
|
|
|
c3a4ccc |
- val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend-id", diskpath));
|
|
|
c3a4ccc |
- diskinfo->backend_id = val ? strtoul(val, NULL, 10) : -1;
|
|
|
c3a4ccc |
- val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/state", diskpath));
|
|
|
c3a4ccc |
+ rc = libxl__backendpath_parse_domid(gc, diskinfo->backend,
|
|
|
c3a4ccc |
+ &diskinfo->backend_id);
|
|
|
c3a4ccc |
+ if (rc) goto out;
|
|
|
c3a4ccc |
+
|
|
|
c3a4ccc |
+ val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", fe_path));
|
|
|
c3a4ccc |
diskinfo->state = val ? strtoul(val, NULL, 10) : -1;
|
|
|
c3a4ccc |
- val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/event-channel", diskpath));
|
|
|
c3a4ccc |
+ val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/event-channel", fe_path));
|
|
|
c3a4ccc |
diskinfo->evtch = val ? strtoul(val, NULL, 10) : -1;
|
|
|
c3a4ccc |
- val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/ring-ref", diskpath));
|
|
|
c3a4ccc |
+ val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/ring-ref", fe_path));
|
|
|
c3a4ccc |
diskinfo->rref = val ? strtoul(val, NULL, 10) : -1;
|
|
|
c3a4ccc |
diskinfo->frontend = xs_read(ctx->xsh, XBT_NULL,
|
|
|
c3a4ccc |
libxl__sprintf(gc, "%s/frontend", diskinfo->backend), NULL);
|
|
|
c3a4ccc |
@@ -2825,6 +2832,10 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
GC_FREE;
|
|
|
c3a4ccc |
return 0;
|
|
|
c3a4ccc |
+
|
|
|
c3a4ccc |
+ out:
|
|
|
c3a4ccc |
+ free(diskinfo->backend);
|
|
|
c3a4ccc |
+ return rc;
|
|
|
c3a4ccc |
}
|
|
|
c3a4ccc |
|
|
|
c3a4ccc |
int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
|
|
|
c3a4ccc |
--
|
|
|
c3a4ccc |
2.1.4
|
|
|
c3a4ccc |
|