From: Olaf Hering <olaf@aepfle.de>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH v11 1/2] libxl: add support for vscsi
Date: Fri, 8 Apr 2016 17:43:17 +0200 [thread overview]
Message-ID: <20160408154317.GA14490@aepfle.de> (raw)
In-Reply-To: <20160408142328.GA6085@citrix.com>
On Fri, Apr 08, Wei Liu wrote:
> On Fri, Apr 08, 2016 at 04:16:46PM +0200, Olaf Hering wrote:
> > What do you have in mind? Something like in vusb_be_from_xs_fe?
> Yes.
Thanks, I will test this change:
Sanitize input from frontend in vscsi_fill_ctrl
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff --git a/tools/libxl/libxl_vscsi.c b/tools/libxl/libxl_vscsi.c
index cbaba82..413e129 100644
--- a/tools/libxl/libxl_vscsi.c
+++ b/tools/libxl/libxl_vscsi.c
@@ -117,27 +117,34 @@ static bool vscsi_fill_dev(libxl__gc *gc,
}
static bool vscsi_fill_ctrl(libxl__gc *gc,
+ uint32_t tgt_domid,
xs_transaction_t t,
const char *fe_path,
const char *dir,
libxl_device_vscsictrl *ctrl)
{
libxl_device_vscsidev dev;
- char *tmp, *be_path, *devs_path;
+ char *tmp, *devs_path;
+ const char *be_path;
char **dev_dirs;
unsigned int ndev_dirs, dev_dir;
+ uint32_t be_domid, fe_domid;
+ char be_type[16];
+ int r;
bool ok;
ctrl->devid = atoi(dir);
- be_path = libxl__xs_read(gc, t, GCSPRINTF("%s/%s/backend", fe_path, dir));
- if (!be_path)
+ tmp = GCSPRINTF("%s/%s/backend", fe_path, dir);
+ r = libxl__xs_read_checked(gc, t, tmp, &be_path);
+ if (r || !be_path)
goto out;
- tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/%s/backend-id", fe_path, dir));
- if (!tmp)
+ r = sscanf(be_path,"/local/domain/%d/backend/%15[^/]/%d",
+ &be_domid, be_type, &fe_domid);
+ if (r != 3 || fe_domid != tgt_domid)
goto out;
- ctrl->backend_domid = atoi(tmp);
+ ctrl->backend_domid = be_domid;
tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/idx", be_path));
if (!tmp)
@@ -205,7 +212,7 @@ static int vscsi_collect_ctrls(libxl__gc *gc,
libxl_device_vscsictrl_init(*ctrls + dir);
libxl_device_vscsictrl_init(&ctrl);
- if (vscsi_fill_ctrl(gc, t, fe_path, dirs[dir], &ctrl)) {
+ if (vscsi_fill_ctrl(gc, domid, t, fe_path, dirs[dir], &ctrl)) {
libxl_device_vscsictrl_copy(CTX, *ctrls + *num, &ctrl);
(*num)++;
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-08 15:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 7:01 [PATCH v11 0/2] libxl: add support for pvscsi, iteration 11 Olaf Hering
2016-04-08 7:01 ` [PATCH v11 1/2] libxl: add support for vscsi Olaf Hering
2016-04-08 8:53 ` Juergen Gross
2016-04-08 10:18 ` Olaf Hering
2016-04-08 12:06 ` Wei Liu
2016-04-08 13:47 ` Ian Jackson
2016-04-08 14:49 ` Wei Liu
2016-04-08 14:16 ` Olaf Hering
2016-04-08 14:23 ` Wei Liu
2016-04-08 15:43 ` Olaf Hering [this message]
2016-04-11 12:57 ` Olaf Hering
2016-04-11 13:02 ` Wei Liu
2016-04-08 14:41 ` Wei Liu
2016-04-08 7:01 ` [PATCH v11 2/2] Scripts to create and delete xen-scsiback nodes in Linux target framework Olaf Hering
2016-04-08 11:05 ` Wei Liu
2016-04-08 11:07 ` Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160408154317.GA14490@aepfle.de \
--to=olaf@aepfle.de \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).