From patchwork Fri Apr 8 15:43:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olaf Hering X-Patchwork-Id: 8784241 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2CBD4C0553 for ; Fri, 8 Apr 2016 15:45:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40DF22026D for ; Fri, 8 Apr 2016 15:45:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 620F020211 for ; Fri, 8 Apr 2016 15:45:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoYZA-0002Xu-4Q; Fri, 08 Apr 2016 15:43:24 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoYZ8-0002Xo-BX for xen-devel@lists.xen.org; Fri, 08 Apr 2016 15:43:22 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 16/40-07120-991D7075; Fri, 08 Apr 2016 15:43:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRWlGSWpSXmKPExsUSuHLSTd2ZF9n DDZb0clgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnP2m+wF5wQrJi1ej1jA+Ntni5GTg4WgVXM Ek1TSkBsCQFfiXUd0xi7GDmAbBGJJ//Tuhi5OIQEHjFJfPn2gwmkRkggXaJn7wZGiF4ViVNP7 oPF2QSUJPYePA4WFxFQlHjw8iYrSDOzwFJGiUXzfzODJIQFLCWOnL/ACmLzCuhJbF78gRliw3 1Gif/vjzJBJAQlTs58wgJiMwuoS/yZd4kZ5CJmAWmJ5f84QMKcAvoSay7eAisRFZCTuHN4C+s ERsFZSLpnIemehdC9gJF5FaN6cWpRWWqRrpFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFe cn7uJkZgyDIAwQ7GZX+dDjFKcjApifLqnGIPF+JLyk+pzEgszogvKs1JLT7EKMPBoSTBO+cCU E6wKDU9tSItMwcYPTBpCQ4eJRHe1yBp3uKCxNzizHSI1ClGRSlx3lUgCQGQREZpHlwbLGIvMc pKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZj3NMgUnsy8Erjpr4AWMwEtvsDPBrK4JBEhJdXA6Kq TVNHQclHLIfzk9+wXy6cdt88zXl4YtIulJ9xv38QAybMHVmxL4tz6t1u7rHOZ529Bxw7Nn6YX Fd5npVdLKfpevRke61JzzzHobL2leoR7SVuc2GmjNad1rPdsuV/FFJ9fMaEu/nV7ZrEU7yzhi 2wz1KyOsN2v7lj8qvrnC8aamhrTlj9KLMUZiYZazEXFiQBr5+c10wIAAA== X-Env-Sender: olaf@aepfle.de X-Msg-Ref: server-6.tower-21.messagelabs.com!1460130200!8270783!1 X-Originating-IP: [81.169.146.217] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59102 invoked from network); 8 Apr 2016 15:43:21 -0000 Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.217) by server-6.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Apr 2016 15:43:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1460130200; l=1965; s=domk; d=aepfle.de; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Subject:Cc:To:From:Date; bh=OYjpg2oEsWUrdggCF86wMVQqnXGQoSgAdiHo+G1A4Dc=; b=kZOLqBykA+Xyoi2+95ujjK5mhPj2z9MaT7kuxkF9RNm+8lxWSGnvUDPcb6VMpQTJ35c eq5SzXACofE7c+pRzqhSsKnzL4CgiC3XyxTe+cyECQIsQP69zapQyyj09eW0dIyfCdY/I SLHLS8A15BP+HpKiVEISO1bZ1R3A1Hlifeg= X-RZG-AUTH: :P2EQZWCpfu+qG7CngxMFH1J+yackYocTD1iAi8x+OWtqWFmrC5F/k8z92bDrkQ== X-RZG-CLASS-ID: mo00 Received: from probook (aftr-185-17-206-120.dynamic.mnet-online.de [185.17.206.120]) by smtp.strato.de (RZmta 37.22 DYNA|AUTH) with ESMTPSA id z01362s38FhIxLK (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 8 Apr 2016 17:43:18 +0200 (CEST) Received: by probook (Postfix, from userid 1000) id 6363750906; Fri, 8 Apr 2016 17:43:17 +0200 (CEST) Date: Fri, 8 Apr 2016 17:43:17 +0200 From: Olaf Hering To: Wei Liu Message-ID: <20160408154317.GA14490@aepfle.de> References: <1460098891-13278-1-git-send-email-olaf@aepfle.de> <1460098891-13278-2-git-send-email-olaf@aepfle.de> <20160408120651.GD10861@citrix.com> <20160408141646.GA12197@aepfle.de> <20160408142328.GA6085@citrix.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160408142328.GA6085@citrix.com> User-Agent: Mutt/1.5.24 (6601) Cc: Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org Subject: Re: [Xen-devel] [PATCH v11 1/2] libxl: add support for vscsi X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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)++; }