From patchwork Thu May 26 15:21:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9137103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07C516075C for ; Thu, 26 May 2016 15:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0E3728098 for ; Thu, 26 May 2016 15:24:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5D30282F5; Thu, 26 May 2016 15:24:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 91DEE28098 for ; Thu, 26 May 2016 15:24:10 +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 1b5x6u-0003s9-JH; Thu, 26 May 2016 15:22:08 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5x6t-0003rq-46 for xen-devel@lists.xenproject.org; Thu, 26 May 2016 15:22:07 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id F0/B0-01004-E9417475; Thu, 26 May 2016 15:22:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42JxWrrBXneuiHu 4weLvFhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bD6m3MBd+lK5bNUmxg/C3axcjBISHgL/F1 WVEXIycHm4CyxM/OXjYQW0RAT6LpwHNGEJtZoFxi/rw2dhBbWMBZ4ueZN2BxFgFVib0zJjCDj OEVcJJ4tr8SJCwhICdx/vhPsDCngIHEyR4ukLCQgL7E4w2fmCBsBYmO6cfAbF4BQYmTM5+wQG ySkDj44gUzxGHcEn+77Scw8s1CUjULSdUCRqZVjBrFqUVlqUW6hqZ6SUWZ6RkluYmZObqGBqZ 6uanFxYnpqTmJScV6yfm5mxiBocQABDsYG7Z7HmKU5GBSEuUVF3cLF+JLyk+pzEgszogvKs1J LT7EKMPBoSTBe+kAUE6wKDU9tSItMwcY1DBpCQ4eJRFeMWH3cCHe4oLE3OLMdIjUKUZFKXHep 0JACQGQREZpHlwbLJIuMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZjXCGQ8T2ZeCdz0V0CLmY AW+39xBllckoiQkmpgZNn++8nZ270T6+8WTvpk49rtflHyyLwjKpr2F4OYvdrWLIxsTbrhFXC +YOKn2T89j5z2k5sX6vSPZXmAgJh17Z9PSztT+4I6ObR3697X3nY2aPrxCLM5Da+vv8hRfCJU ZvsxwP6m/9e+VWU+Kr7qZv8eJumXXYuakG/Wfyqjq+Jt8jne8FxnJZbijERDLeai4kQAShd/v p8CAAA= X-Env-Sender: prvs=947cb6223=wei.liu2@citrix.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1464276123!41588759!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58458 invoked from network); 26 May 2016 15:22:04 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 26 May 2016 15:22:04 -0000 X-IronPort-AV: E=Sophos;i="5.26,367,1459814400"; d="scan'208";a="363632834" From: Wei Liu To: Xen-devel Date: Thu, 26 May 2016 16:21:55 +0100 Message-ID: <1464276116-8412-1-git-send-email-wei.liu2@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20160526151957.GX22076@citrix.com> References: <20160526151957.GX22076@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Anthony PERARD , Wei Liu , Ian Jackson Subject: [Xen-devel] [PATCH for-4.7] libxl: set XEN_QEMU_CONSOLE_LIMIT for QEMU 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-Virus-Scanned: ClamAV using ClamSMTP XSA-180 provides a patch to QEMU to bodge QEMU logging issue. We explicitly set the limit in libxl for 4.7. Introduce a function for setting the environment variable and call it in the right places. Signed-off-by: Wei Liu Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 6bbc7c3..1412c29 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -365,6 +365,24 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, return ERROR_FAIL; } +/* XSA-180 / CVE-2014-3672 + * + * The QEMU shipped with Xen has a bodge. It checks for + * XEN_QEMU_CONSOLE_LIMIT to see how much data QEMU is allowed + * to write to stderr. We set that to 1MB if it is not set by + * system administrator. + */ +static void libxl__set_qemu_env_for_xsa_180(libxl__gc *gc, + flexarray_t *dm_envs) +{ + unsigned long limit = 0; + const char *s = getenv("XEN_QEMU_CONSOLE_LIMIT"); + + limit = s ? strtoul(s,0,0) : 1*1024*1024; + flexarray_append_pair(dm_envs, "XEN_QEMU_CONSOLE_LIMIT", + GCSPRINTF("%lu", limit)); +} + const libxl_vnc_info *libxl__dm_vnc(const libxl_domain_config *guest_config) { const libxl_vnc_info *vnc = NULL; @@ -415,6 +433,8 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, dm_args = flexarray_make(gc, 16, 1); dm_envs = flexarray_make(gc, 16, 1); + libxl__set_qemu_env_for_xsa_180(gc, dm_envs); + flexarray_vappend(dm_args, dm, "-d", GCSPRINTF("%d", domid), NULL); @@ -913,6 +933,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, dm_args = flexarray_make(gc, 16, 1); dm_envs = flexarray_make(gc, 16, 1); + libxl__set_qemu_env_for_xsa_180(gc, dm_envs); + flexarray_vappend(dm_args, dm, "-xen-domid", GCSPRINTF("%d", guest_domid), NULL); @@ -2193,8 +2215,8 @@ static void device_model_spawn_outcome(libxl__egc *egc, void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) { STATE_AO_GC(dmss->spawn.ao); - flexarray_t *dm_args; - char **args; + flexarray_t *dm_args, *dm_envs; + char **args, **envs; const char *dm; int logfile_w, null = -1, rc; uint32_t domid = dmss->guest_domid; @@ -2203,6 +2225,8 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) dm = qemu_xen_path(gc); dm_args = flexarray_make(gc, 15, 1); + dm_envs = flexarray_make(gc, 1, 1); + flexarray_vappend(dm_args, dm, "-xen-domid", GCSPRINTF("%d", domid), NULL); flexarray_append(dm_args, "-xen-attach"); @@ -2216,6 +2240,9 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) flexarray_append(dm_args, NULL); args = (char **) flexarray_contents(dm_args); + libxl__set_qemu_env_for_xsa_180(gc, dm_envs); + envs = (char **) flexarray_contents(dm_envs); + logfile_w = libxl__create_qemu_logfile(gc, GCSPRINTF("qdisk-%u", domid)); if (logfile_w < 0) { rc = logfile_w; @@ -2253,7 +2280,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) goto out; if (!rc) { /* inner child */ setsid(); - libxl__exec(gc, null, logfile_w, logfile_w, dm, args, NULL); + libxl__exec(gc, null, logfile_w, logfile_w, dm, args, envs); } rc = 0;