From patchwork Sat Sep 22 14:53:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 10611425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCD7815E8 for ; Sat, 22 Sep 2018 14:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C45912ADD3 for ; Sat, 22 Sep 2018 14:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B86432ADE1; Sat, 22 Sep 2018 14:53:58 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E847C2ADD3 for ; Sat, 22 Sep 2018 14:53:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CD558E0002; Sat, 22 Sep 2018 10:53:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 57C498E0001; Sat, 22 Sep 2018 10:53:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46C618E0002; Sat, 22 Sep 2018 10:53:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id F04FF8E0001 for ; Sat, 22 Sep 2018 10:53:55 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id d1-v6so7884721pfo.16 for ; Sat, 22 Sep 2018 07:53:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to :subject:date:message-id:mime-version; bh=3pbAYH7OdDjXrxf/g48YbztiIN9svxSSQ0C6GFQQfvI=; b=PyvJ4UM3tydLqq/CMyVHh7kICZcjDIdnXfM3uI07bg/Lb9Os7thCHvEfJHMFpi2NZM XSjYoSGsRJTVIBmSEoZ0RlvN0DqrFrdbPNYwiJaWNAvM+uluwa/xzDBDWRBZhWBpAWZ/ JqH3rRSfX2f5jVTmyAuLtGflzoOiT893zqsRPMLOddIgCT7vKqfhpGI3mFj7qOgTAZf/ clkzSTFAZZUHvYr90sS31s3HWwa2Al6ZJGfrAbjRumOUpjMaWXMnWN/poTAcsARJEyOj 5J+WdUwpssc1lOI+EPJ4D5Qa1tEqmQMYBGFTbeyrvaQgx8yTYaZ1/ZnxTtmpEXf+g+5A SgMg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.1.11 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com X-Gm-Message-State: ABuFfoj6YMCRa0ZLDkqLAZN0gGMbJeeFQT4/UiS9xi6+LlTnzENSMLVx TdYVsYL+Z1vC1v0lYLbBpM2njf0UsHWifo0kXc7HFvUOYP2Vs5o0pCe3iOp35+Eh//VBTwYibKB 0DLJZhO08be+hYECoWMnI490bQ46hzwSkptJmGub19sJGbj8gVqBaiyiy8AAOIWir3g== X-Received: by 2002:a17:902:aa49:: with SMTP id c9-v6mr2914230plr.195.1537628035566; Sat, 22 Sep 2018 07:53:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV618RaWO4bbXO51XdsBqtHBMlK7X8TaijU0WI94viuo+1fYw7LWc7OIgccDrRdj4rzPPw/cz X-Received: by 2002:a17:902:aa49:: with SMTP id c9-v6mr2914182plr.195.1537628034365; Sat, 22 Sep 2018 07:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537628034; cv=none; d=google.com; s=arc-20160816; b=OdhO0vaPGJPJr7v2lRXhwyJn8Sh9wFe7l+u/qrTPPUA4runeaaEWL6shcbvWI39Zcj WUiPfnWgTBpASbhxi8j/v4Vik8ifeeqsAUQ7NAIyax31KdMhquSoo/ERAvJR4f3xpq+7 3LMrKm/S/H87NlcGjOkE9mhVYGXgYfbNNBUeOvMld/hGfBUpCTa4cPshs0LhqRbJGSiQ mM6XWj85CFj6jOitvXW1THWGq3RCyW3X1ddjD3M2TDa7cq7x89XXf3+4W9vKeS8XrSsn xqZPhe8KTNtrkUy4dlBkkpF5lNcsU9/ztNsrCH5FGxMvABrpOdUBQywbWoQChFaots7A 7o0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:to:from; bh=3pbAYH7OdDjXrxf/g48YbztiIN9svxSSQ0C6GFQQfvI=; b=ytlPDi3Yhn+gsm5DY4H6a4rXg497n2hECw/a80HBP2Arwyv9c/L6gqAO83TpsEf8s/ nR660ykrXd5cBPPLPTdGnm+z4Pkq9819OOTJnwZGeaWLZQItGII+EICKcT0yDLHfSQMh C9hCfHavIVY9DH9UB5J9N6+1Ed5xFRxkF+Q7u8AO3cHN0zqEwaLeR+kWqRogUaseCzSg JDRGO57i93derEkyJxMWvo2QembV9EKn75JjcXvrnoWuiutRzh3K11wX0nv030KiUHcj mnnWW9AW98bxw0i1GQlVJNTzJBvGJVI+7xMpK6P3BxpBWryEsTbZSHQSOGG9I3w3Jrce V9iQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.1.11 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com Received: from mail.windriver.com (mail.windriver.com. [147.11.1.11]) by mx.google.com with ESMTPS id 14-v6si5871881pgm.488.2018.09.22.07.53.53 for (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Sep 2018 07:53:54 -0700 (PDT) Received-SPF: pass (google.com: domain of zhe.he@windriver.com designates 147.11.1.11 as permitted sender) client-ip=147.11.1.11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.1.11 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com Received: from ALA-HCB.corp.ad.wrs.com ([147.11.189.41]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w8MErncT013924 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Sat, 22 Sep 2018 07:53:49 -0700 (PDT) Received: from pek-lpg-core2.corp.ad.wrs.com (128.224.153.41) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.408.0; Sat, 22 Sep 2018 07:53:36 -0700 From: To: , , , , , , , , , , Subject: [PATCH v2 1/2] mm/page_alloc: Fix panic caused by passing debug_guardpage_minorder or kernelcore to command line Date: Sat, 22 Sep 2018 22:53:32 +0800 Message-ID: <1537628013-243902-1-git-send-email-zhe.he@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: He Zhe debug_guardpage_minorder_setup and cmdline_parse_kernelcore do not check input argument before using it. The argument would be a NULL pointer if "debug_guardpage_minorder" or "kernelcore", without its value, is set in command line and thus causes the following panic. PANIC: early exception 0xe3 IP 10:ffffffffa08146f1 error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #11 [ 0.000000] RIP: 0010:parse_option_str+0x11/0x90 ... [ 0.000000] Call Trace: [ 0.000000] cmdline_parse_kernelcore+0x19/0x41 [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4ee [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0 This patch adds a check to prevent the panic and adds KBUILD_MODNAME to prints. Signed-off-by: He Zhe Cc: stable@vger.kernel.org Cc: akpm@linux-foundation.org Cc: mhocko@suse.com Cc: vbabka@suse.cz Cc: pasha.tatashin@oracle.com Cc: mgorman@techsingularity.net Cc: aaron.lu@intel.com Cc: osalvador@suse.de Cc: iamjoonsoo.kim@lge.com --- v2: Use more clear error info Split the addition of KBUILD_MODNAME out mm/page_alloc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 89d2a2a..f34cae1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -630,6 +630,12 @@ static int __init debug_guardpage_minorder_setup(char *buf) { unsigned long res; + if (!buf) { + pr_err("kernel option debug_guardpage_minorder requires an \ + argument\n"); + return -EINVAL; + } + if (kstrtoul(buf, 10, &res) < 0 || res > MAX_ORDER / 2) { pr_err("Bad debug_guardpage_minorder value\n"); return 0; @@ -6952,6 +6958,11 @@ static int __init cmdline_parse_core(char *p, unsigned long *core, */ static int __init cmdline_parse_kernelcore(char *p) { + if (!p) { + pr_err("kernel option kernelcore requires an argument\n"); + return -EINVAL; + } + /* parse kernelcore=mirror */ if (parse_option_str(p, "mirror")) { mirrored_kernelcore = true; From patchwork Sat Sep 22 14:53:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 10611427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5777F913 for ; Sat, 22 Sep 2018 14:54:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4753C2ADD3 for ; Sat, 22 Sep 2018 14:54:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B3A22ADD6; Sat, 22 Sep 2018 14:54:01 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6ACB2ADE1 for ; Sat, 22 Sep 2018 14:54:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9043E8E0003; Sat, 22 Sep 2018 10:53:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8B47C8E0001; Sat, 22 Sep 2018 10:53:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7042D8E0003; Sat, 22 Sep 2018 10:53:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 37D6B8E0001 for ; Sat, 22 Sep 2018 10:53:58 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id 3-v6so7496009plq.6 for ; Sat, 22 Sep 2018 07:53:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to :subject:date:message-id:in-reply-to:references:mime-version; bh=CHGC7b7pph0yCvqnm/8NZnEmG+KsK0vA+7BN7swDiYY=; b=tJTirBK7vXlYkfBLIqMh7gDlwtCBEuE/22SgiZ/W+YY78mD5S2vUTnCBTxaky1QYD/ hANedwG0LB+ify5t8MKwShpjfjHWzRk+UvutbEgEziEV0utsX7dg8bZFp7KqWMQ0UJDf ah46XgAFdvRy9vASQx3E27zOHKbTbaVJ7uFAc5jIKHrftVWYAiWC/Che2lWfaj/wN5Ez 4Q4DH45/9zVF/lf5b14rPIvJ4bvFBNAjiJPrj2/yyj/4EyNJUN6PqZ6AwKAusS1EvAbN 1nycUY+6hA9NSe60UlxTlyI/tJDK9lKkutoHbiEtqFAwl3WHpQ/v6Muc255YIJMZyDqb UHnw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.146.13 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com X-Gm-Message-State: ABuFfoiwg+mZ54lqxunZOYjuSFfyiDhfzm0g+8+rbrzzKiJHbO9+AvYy +OG7z2vVxxpBhvP0N511/WWyRgjtQ9xIPX0DSTknuCI+hyo4fdVL7A2CCGPVo8EeTo4TIDQYpIR wqub+eMNwRlSALZAF4qYlRMVlDBYLU1TQap60HKv8F3duT0LppRV3WPedae0hadiwBg== X-Received: by 2002:a17:902:6f10:: with SMTP id w16-v6mr2932830plk.216.1537628037861; Sat, 22 Sep 2018 07:53:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63PUubWI1qMV3e/sr3o3CFZkOCFbcS9Pxy9t3g4JwfmIRGZqYj5gpvspDKQ9WkaEEk9iVO9 X-Received: by 2002:a17:902:6f10:: with SMTP id w16-v6mr2932792plk.216.1537628037000; Sat, 22 Sep 2018 07:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537628036; cv=none; d=google.com; s=arc-20160816; b=UDUuVoHjkvn77I4jo5pVgOuuw8bJ54MWufo1gKZEZVCEL2mWCf9r80sCPitmMvywH/ frOuw92yOI+Iw3pMt5OTHAHDQ146oZXTb3cXRoNqYhyvn0y07c69vt4m7j2EcndpCizf qlmDPUI0tX4KpMuNIqedZj+nEz+Gjofs5cnJDEOWqu8caCeHj/Be/zNsGnmXRy318lNt MUUWRZgpbEg6r04z07vnQOxYyEGNgwWRDBEQDz9Fo0zharc6YdZpI3DGbP/cKECSUT2A PTXaqf/qyHt7zSgKn+ZOaOALYo8JVJBlS8EDAJQcRZKYq+qz7cQKn1rAohui+09y5BQc hkzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=CHGC7b7pph0yCvqnm/8NZnEmG+KsK0vA+7BN7swDiYY=; b=kNOLOjK/lcEhMxr6GuHcRVLb8/ey4yJhaQtpHtNMIaGcgUwEu2c3X1z0fHpF4dac90 jguMTWdPwFaQf7CnxuqCFp3+xQgXccZN7OYEiePJHKUtnmYfmG7IKG9XMw841OUOzZXc +0FlSdOD5LYnWoZZKW66dddkEnkwHss5jPpNoUyPIbu4vuuLR1+iKfaouo7r1bbRoV0o wZC/Z6AKeN7tcHxWGKCmIjxeUWm6jFrpyEw/6hyu36+AIY6a2x61cbtIYWMV9tp2wfzq IJ1ebuI5z10Z/yn/Lmmzo6PoyNZm8CeExeZ+m51WZzRNPJAbXuX6EKkH5W0XYqZCi3u6 11aQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.146.13 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com Received: from mail1.windriver.com (mail1.windriver.com. [147.11.146.13]) by mx.google.com with ESMTPS id h14-v6si29898117pgg.540.2018.09.22.07.53.56 for (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Sep 2018 07:53:56 -0700 (PDT) Received-SPF: pass (google.com: domain of zhe.he@windriver.com designates 147.11.146.13 as permitted sender) client-ip=147.11.146.13; Authentication-Results: mx.google.com; spf=pass (google.com: domain of zhe.he@windriver.com designates 147.11.146.13 as permitted sender) smtp.mailfrom=Zhe.He@windriver.com Received: from ALA-HCB.corp.ad.wrs.com ([147.11.189.41]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id w8MErt8E017391 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Sat, 22 Sep 2018 07:53:55 -0700 (PDT) Received: from pek-lpg-core2.corp.ad.wrs.com (128.224.153.41) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.408.0; Sat, 22 Sep 2018 07:53:54 -0700 From: To: , , , , , , , , , , Subject: [PATCH v2 2/2] mm/page_alloc: Add KBUILD_MODNAME Date: Sat, 22 Sep 2018 22:53:33 +0800 Message-ID: <1537628013-243902-2-git-send-email-zhe.he@windriver.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537628013-243902-1-git-send-email-zhe.he@windriver.com> References: <1537628013-243902-1-git-send-email-zhe.he@windriver.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: He Zhe Add KBUILD_MODNAME to make prints more clear. Signed-off-by: He Zhe Cc: akpm@linux-foundation.org Cc: mhocko@suse.com Cc: vbabka@suse.cz Cc: pasha.tatashin@oracle.com Cc: mgorman@techsingularity.net Cc: aaron.lu@intel.com Cc: osalvador@suse.de Cc: iamjoonsoo.kim@lge.com --- v2: Split the addition of KBUILD_MODNAME out mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f34cae1..ead9556 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -14,6 +14,8 @@ * (lots of bits borrowed from Ingo Molnar & Andrew Morton) */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include