From patchwork Thu Sep 14 08:57:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9952621 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 5A5B460230 for ; Thu, 14 Sep 2017 08:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BD8728862 for ; Thu, 14 Sep 2017 08:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 406DA28DC6; Thu, 14 Sep 2017 08:59:47 +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 B9BE928862 for ; Thu, 14 Sep 2017 08:59:46 +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 1dsPxb-0001sF-Rj; Thu, 14 Sep 2017 08:57:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsPxZ-0001s9-VQ for xen-devel@lists.xenproject.org; Thu, 14 Sep 2017 08:57:22 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 45/92-15060-1744AB95; Thu, 14 Sep 2017 08:57:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsXS6fjDSzffZVe kwa4Nuhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bkyfeYCn6IVSzZuJaxgfEpfxcjJ4eQQJ7E 8c9vGEFsXgE7ifX/PzGB2BIChhKnF95kAbFZBFQlvn7cwAZiswmoS7Q9287axcjBISJgIHHua BJImFmgXGJF41NGkLAwUPjifAmI6XYSx1Z8YwMJ8woISvzdIQxRrSXx8NctFghbW2LZwtfMIC XMAtISy/9xTGDknYXQMAtJwywkDbMQGhYwsqxi1ChOLSpLLdI1NtRLKspMzyjJTczM0TU0MNP LTS0uTkxPzUlMKtZLzs/dxAgMMAYg2MHYtCjwEKMkB5OSKO9e3Z2RQnxJ+SmVGYnFGfFFpTmp xYcYZTg4lCR4PZ13RQoJFqWmp1akZeYAQx0mLcHBoyTCaw+S5i0uSMwtzkyHSJ1i1OXouHn3D 5MQS15+XqqUOK8jSJEASFFGaR7cCFjcXWKUlRLmZQQ6SoinILUoN7MEVf4VozgHo5IwrwLIFJ 7MvBK4Ta+AjmACOuLM6R0gR5QkIqSkGhi3+G7t+Hht+yufL1ZLJrGuVkg6PVNs8kGNRX9iCrl t2yyKj4R57PAoLpbL3ttYGGxxTkTZ037htf+JTw4bvTwSJyzL7/FiS6RgudU2CY5ft9p0Ss7P bl6y9vc71Z5H/0//fXVU+U+pQ4Gx2t2vbettskX9TbmmC1goaayfPYfp/trX1kob5p9SYinOS DTUYi4qTgQAt35FSbYCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1505379438!116889492!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14482 invoked from network); 14 Sep 2017 08:57:19 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Sep 2017 08:57:19 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 14 Sep 2017 02:57:17 -0600 Message-Id: <59BA608C020000780017AFC9@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Thu, 14 Sep 2017 02:57:16 -0600 From: "Jan Beulich" To: "xen-devel" References: <59BA608C020000780017AFC9@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Cc: Juergen Gross , Andrew Cooper , Kevin Tian Subject: [Xen-devel] [PATCH] custom parameter handling fixes 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 The recent changes to their handling introduced a few false warnings, due to checks looking at the wrong string slot. While going through all those commits and looking for patterns similar to the "dom0_mem=" I've noticed this with, I also realized that there were other issues with "dom0_nodes=" and "rmrr=", partly pre-existing, but partly also due to those recent changes not having gone far enough. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian Acked-by: Andrew Cooper --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -59,7 +59,7 @@ static int __init parse_dom0_mem(const c dom0_nrpages = parse_amt(s, &s); } while ( *s++ == ',' ); - return *s ? -EINVAL : 0; + return s[-1] ? -EINVAL : 0; } custom_param("dom0_mem", parse_dom0_mem); @@ -94,7 +94,13 @@ static int __init parse_dom0_nodes(const { do { if ( isdigit(*s) ) + { + if ( dom0_nr_pxms >= ARRAY_SIZE(dom0_pxms) ) + return -E2BIG; dom0_pxms[dom0_nr_pxms] = simple_strtoul(s, &s, 0); + if ( !*s || *s == ',' ) + ++dom0_nr_pxms; + } else if ( !strncmp(s, "relaxed", 7) && (!s[7] || s[7] == ',') ) { dom0_affinity_relaxed = true; @@ -106,10 +112,10 @@ static int __init parse_dom0_nodes(const s += 6; } else - break; - } while ( ++dom0_nr_pxms < ARRAY_SIZE(dom0_pxms) && *s++ == ',' ); + return -EINVAL; + } while ( *s++ == ',' ); - return *s ? -EINVAL : 0; + return s[-1] ? -EINVAL : 0; } custom_param("dom0_nodes", parse_dom0_nodes); --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -1097,15 +1097,18 @@ static int __init parse_rmrr_param(const unsigned long start, end; do { + if ( nr_rmrr >= MAX_USER_RMRR ) + return -E2BIG; + start = simple_strtoul(cur = s, &s, 16); if ( cur == s ) - break; + return -EINVAL; if ( *s == '-' ) { end = simple_strtoul(cur = s + 1, &s, 16); if ( cur == s ) - break; + return -EINVAL; } else end = start; @@ -1121,7 +1124,7 @@ static int __init parse_rmrr_param(const stmp = parse_pci_seg(s + 1, &seg, &bus, &dev, &func, &def_seg); if ( !stmp ) - break; + return -EINVAL; /* * Not specified. @@ -1142,8 +1145,8 @@ static int __init parse_rmrr_param(const if ( user_rmrrs[nr_rmrr].dev_count ) nr_rmrr++; - } while ( *s++ == ';' && nr_rmrr < MAX_USER_RMRR ); + } while ( *s++ == ';' ); - return *s ? -EINVAL : 0; + return s[-1] ? -EINVAL : 0; } custom_param("rmrr", parse_rmrr_param);