Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3633286imm; Mon, 20 Aug 2018 01:58:36 -0700 (PDT) X-Google-Smtp-Source: AA+uWPymiWTqmkWkBCxTQ1a+n7hMjfan8cyyECvoLwmySqi2vMScYeTDp1t8LO86G3IdXApGDe14 X-Received: by 2002:a62:6c04:: with SMTP id h4-v6mr12743845pfc.113.1534755516653; Mon, 20 Aug 2018 01:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534755516; cv=none; d=google.com; s=arc-20160816; b=xZv8p729bwOFTt/enVh6uIubstvXNmNFGaAmOmSD00lZiQLX1dNfp5sKlyg9ATwoSL EZFO29DCGvwIxOd2JfxM6FCTo6VxxzyMfDFrOW/dqJUDYmeyqnhxiirD7xjffHx6w+89 m5Hb09jrinBU+9G4I1o38ZqwcNsQEAIzCVBSPqJS7dafJqhQS71qoLTvmFQWA9TXOA1S +xEUB2f6ckBeOsMpfp/R6wk5ezT1MJGVCXyr8haxmU6fhsc1VxKHh8l8BVA2iq0N+Xjb RtN1xwvAiFSnpzFuHIHyT6Zpe0FOkHbi2KuZVIel+ADllWy9ZHZD2F31/K1J0Sas0gXn jUmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=aKjeHpeTO/Yz00lh7EQWWLmOM3ZphEXv/ryu89R54fM=; b=WrfwfbQWSmT/gytK/dzjeDhvL2QVgRYviL8Zow/3ylhOqxi/uGJn3WEHEToeN8lrr6 mSv0Eb4zHZ5vv4HxHSYytV2IjcSwF7MCIKA7daZTlHzMGlQ5PaXaQEHppxly4MKZbiVn NegUrEpkaL96XdFw3A8uCbVX7oCaP2mSqcnPY3Wy9rjb4zVLuv5eHOzzfO+WRi0vD00P FiNVM8LNJABuMAfSU1zMYIXLEWTNqH28o/llOscM+HuULqDB5nsWxvgKeMBxJOPbIl5l n1/a+SQxcuhldRT7m52Lps7g6wwJK0vGA3EPUMG7k4/Yk5NgkrU0hJjCXlQnqzc3Dc/s VfDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4-v6si8806959pga.320.2018.08.20.01.58.21; Mon, 20 Aug 2018 01:58:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbeHTMLj (ORCPT + 99 others); Mon, 20 Aug 2018 08:11:39 -0400 Received: from mail5.windriver.com ([192.103.53.11]:44734 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbeHTMLi (ORCPT ); Mon, 20 Aug 2018 08:11:38 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id w7K8uT24006167 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 20 Aug 2018 01:56:29 -0700 Received: from [128.224.162.216] (128.224.162.216) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.399.0; Mon, 20 Aug 2018 01:56:28 -0700 Subject: Re: [PATCH v2 1/2] x86: corruption-check: Passing memory_corruption_check to command line causes panic To: , , , , , , , References: <1534260823-87917-1-git-send-email-zhe.he@windriver.com> From: He Zhe Message-ID: <129aaffb-7f8d-cf84-cf2d-8e95e303908a@windriver.com> Date: Mon, 20 Aug 2018 16:56:22 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1534260823-87917-1-git-send-email-zhe.he@windriver.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [128.224.162.216] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Could you please provide your input? Thanks. Zhe On 2018年08月14日 23:33, zhe.he@windriver.com wrote: > From: He Zhe > > memory_corruption_check[{_period|_size}]'s handlers do not check input > argument before passing it to kstrtoul or simple_strtoull. The argument > would be a NULL pointer if each of the kernel parameters, without its > value, is set in command line and thus cause the following panic. > > PANIC: early exception 0xe3 IP 10:ffffffff73587c22 error 0 cr2 0x0 > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #2 > [ 0.000000] RIP: 0010:kstrtoull+0x2/0x10 > ... > [ 0.000000] Call Trace > [ 0.000000] ? set_corruption_check+0x21/0x49 > [ 0.000000] ? do_early_param+0x4d/0x82 > [ 0.000000] ? parse_args+0x212/0x330 > [ 0.000000] ? rdinit_setup+0x26/0x26 > [ 0.000000] ? parse_early_options+0x20/0x23 > [ 0.000000] ? rdinit_setup+0x26/0x26 > [ 0.000000] ? parse_early_param+0x2d/0x39 > [ 0.000000] ? setup_arch+0x2f7/0xbf4 > [ 0.000000] ? start_kernel+0x5e/0x4c2 > [ 0.000000] ? load_ucode_bsp+0x113/0x12f > [ 0.000000] ? secondary_startup_64+0xa5/0xb0 > > This patch adds checks to prevent the panic. > > Cc: stable@vger.kernel.org > Signed-off-by: He Zhe > --- > v2: > - Split out printk cleanups > - Add cc to stable@vger.kernel.org > - Use more meaningful error message > > arch/x86/kernel/check.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c > index 3339942..cc8258a 100644 > --- a/arch/x86/kernel/check.c > +++ b/arch/x86/kernel/check.c > @@ -31,6 +31,11 @@ static __init int set_corruption_check(char *arg) > ssize_t ret; > unsigned long val; > > + if (!arg) { > + pr_err("memory_corruption_check config string not provided\n"); > + return -EINVAL; > + } > + > ret = kstrtoul(arg, 10, &val); > if (ret) > return ret; > @@ -45,6 +50,11 @@ static __init int set_corruption_check_period(char *arg) > ssize_t ret; > unsigned long val; > > + if (!arg) { > + pr_err("memory_corruption_check_period config string not provided\n"); > + return -EINVAL; > + } > + > ret = kstrtoul(arg, 10, &val); > if (ret) > return ret; > @@ -59,6 +69,11 @@ static __init int set_corruption_check_size(char *arg) > char *end; > unsigned size; > > + if (!arg) { > + pr_err("memory_corruption_check_size config string not provided\n"); > + return -EINVAL; > + } > + > size = memparse(arg, &end); > > if (*end == '\0')