From patchwork Wed Sep 15 00:53:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBB44C433EF for ; Wed, 15 Sep 2021 00:53:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5639161242 for ; Wed, 15 Sep 2021 00:53:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5639161242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E79C76B006C; Tue, 14 Sep 2021 20:53:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E570F940008; Tue, 14 Sep 2021 20:53:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3B2F940007; Tue, 14 Sep 2021 20:53:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id C676C6B006C for ; Tue, 14 Sep 2021 20:53:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8025430177 for ; Wed, 15 Sep 2021 00:53:09 +0000 (UTC) X-FDA: 78587983698.13.5E97787 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP id 38246B0000A3 for ; Wed, 15 Sep 2021 00:53:09 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 54E3061165; Wed, 15 Sep 2021 00:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667188; bh=sKvjf2fiiYwNnsu3EWnRbm2IWieh3kqYhZMnjiu1GMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2qweMngdGf7vLP9t+edQUOaQ/BYkkuPzneCCroClzxX0lLigowVrMrWTS1OQcV0F aO+HeHOiF31fbPlISjgAla6TwpGuMswVe13wGRfrsri3exSHoN/680zOpTMtNy/kdI OZZVBIMgjNAMbtmvBwIAc5PNn3o2SrA0AizZ/+Y5wzJz3GTwDgyuXwn68TRFSOABlX cUij6FGxgSaZH4JL/YB2BBAn7jOLwWmw4mHevSNAIbxZXzpsw5IjgCmOhfafrLgAhK q4+CFPGFIZgcfB6MmQI+VeobecggDh5aNboGvA0RR5go7jlMAWDEK8saSSwpTNe6Aq XZ/N0LwrmTEFQ== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 1/5] bootconfig: Fix to check the xbc_node is used before free it Date: Wed, 15 Sep 2021 09:53:06 +0900 Message-Id: <163166718582.510331.11732633028925882626.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 38246B0000A3 X-Stat-Signature: fp736czz1e6yrah9njnswyhskdpnuumh Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=J2qweMng; spf=pass (imf19.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1631667189-53940 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: Fix to check the xbc_node is used before calling memblock_free() because passing NULL to phys_addr() will cause a panic. This will happen if user doesn't pass any bootconfig to the kernel, because kernel will call xbc_destroy_all() after booting. Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") Reported-by: kernel test robot Signed-off-by: Masami Hiramatsu --- Changes in v2: - Rebase on top of Linus tree. --- lib/bootconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bootconfig.c b/lib/bootconfig.c index 5ae248b29373..bee691ea8213 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -792,7 +792,8 @@ void __init xbc_destroy_all(void) xbc_data = NULL; xbc_data_size = 0; xbc_node_num = 0; - memblock_free_ptr(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX); + if (xbc_nodes) + memblock_free_ptr(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX); xbc_nodes = NULL; brace_index = 0; } From patchwork Wed Sep 15 00:53:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D21B7C433EF for ; Wed, 15 Sep 2021 00:53:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 67C9B61242 for ; Wed, 15 Sep 2021 00:53:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 67C9B61242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 06B9F6B0072; Tue, 14 Sep 2021 20:53:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01ADD940008; Tue, 14 Sep 2021 20:53:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7A98940007; Tue, 14 Sep 2021 20:53:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id DAFA46B0072 for ; Tue, 14 Sep 2021 20:53:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 79AE73A7C2 for ; Wed, 15 Sep 2021 00:53:17 +0000 (UTC) X-FDA: 78587984034.03.C99E626 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP id 3F380F000090 for ; Wed, 15 Sep 2021 00:53:17 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B0E261184; Wed, 15 Sep 2021 00:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667196; bh=tjYE+w+hVKFuNE7M94ifyu2S6XUIpnaX8UMLFXe0coU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lw+x3M5cCMkeL7uU6t+ypFcqKpSGYAIHsSK5xSYO5AqJ9q1cv7It52GQzfMf9s3VR HQI0zPcUBg0ByxPU+fYataZ4ThsM2ycGnHjwKFhjMKh0lAUpNzxjUcT2si9zcTa9Rz Yo0/l5bhL37/PwA7KAIru4GI0ekzWeO3nYlbGbc435fj8AxickBdntfam1uvGIuNUf UaeX4ArMI+ImR0fa6OCVpj2TRAMDkGMj8csPWyYZcTCbLg/3Sq7yFFHvhOQowGIA9R NS98VYG+7Wl39xGCdlXM0fUyTxMXrTLFvFTeFNFOp6vBvezNUxqDeSvAdpdhyQLEZE liBpiEGhMzaEA== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 2/5] bootconfig: init: Fix memblock leak in xbc_make_cmdline() Date: Wed, 15 Sep 2021 09:53:14 +0900 Message-Id: <163166719378.510331.1159980452908668023.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 3F380F000090 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lw+x3M5c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org X-Stat-Signature: uxywonegasprwuhe1wudcwyrpcsudx9r X-HE-Tag: 1631667197-429185 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: Free unused memblock in a error case to fix memblock leak in xbc_make_cmdline(). Fixes: 51887d03aca1 ("bootconfig: init: Allow admin to use bootconfig for kernel command line") Signed-off-by: Masami Hiramatsu --- init/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/init/main.c b/init/main.c index 3f7216934441..0b054fff8e92 100644 --- a/init/main.c +++ b/init/main.c @@ -382,6 +382,7 @@ static char * __init xbc_make_cmdline(const char *key) ret = xbc_snprint_cmdline(new_cmdline, len + 1, root); if (ret < 0 || ret > len) { pr_err("Failed to print extra kernel cmdline.\n"); + memblock_free_ptr(new_cmdline, len + 1); return NULL; } From patchwork Wed Sep 15 00:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A9ABC433EF for ; Wed, 15 Sep 2021 00:53:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC66A61165 for ; Wed, 15 Sep 2021 00:53:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC66A61165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5ED51940007; Tue, 14 Sep 2021 20:53:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5998F6B0074; Tue, 14 Sep 2021 20:53:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4882B940007; Tue, 14 Sep 2021 20:53:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 3C2416B0073 for ; Tue, 14 Sep 2021 20:53:26 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F13E03A7C1 for ; Wed, 15 Sep 2021 00:53:25 +0000 (UTC) X-FDA: 78587984370.30.E9AE12B Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf24.hostedemail.com (Postfix) with ESMTP id B4072B0000A0 for ; Wed, 15 Sep 2021 00:53:25 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D4326103B; Wed, 15 Sep 2021 00:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667205; bh=3BaNmCZTv0c11pAEto4TWOw5JJNkPY3QPpJT3D6yH7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g86IkxSDnxmpvSl4SA0OUao7b8oHAidoBLVipURaY0Z4Rd7VYJtOr1qJL/mdzZs9y /AccSRLvdl+E/Kjge7FrrCJll/UKEcW9GfeZuS1pkNuZdhea/mOziyPTxO/PeWhPJS mW3PdRm+YqY4myc6V99F0gc1LDCrlqXf5uuH/JR9JLaTT4JGFzHzMutlxz7nLhsGVj mi0zeUChV8oLVCXg5WlWhvmQxhDsjOsHqy5K4v959knj2NG1mypYAreuLjT0WlnpYG Z1OH0Egy9hFqR1E0xUoyVMg1JWbg4Tz1aLA8r8+21cgTk22fy9V1J3jjKTrKhhoyeE eWDzRRdceiyVg== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 3/5] bootconfig: init: Fix memblock leak in setup_boot_config() Date: Wed, 15 Sep 2021 09:53:21 +0900 Message-Id: <163166720179.510331.2971582309563797048.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=g86IkxSD; spf=pass (imf24.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: apsrd4ooukip5nanup36n13hhr65owqw X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B4072B0000A0 X-HE-Tag: 1631667205-551421 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: Free unused memblock in a error case to fix memblock leak in setup_boot_config(). Fixes: 7684b8582c24 ("bootconfig: Load boot config from the tail of initrd") Signed-off-by: Masami Hiramatsu --- init/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/init/main.c b/init/main.c index 0b054fff8e92..4f059fde1df0 100644 --- a/init/main.c +++ b/init/main.c @@ -459,6 +459,7 @@ static void __init setup_boot_config(void) else pr_err("Failed to parse bootconfig: %s at %d.\n", msg, pos); + memblock_free_ptr(copy, size + 1); } else { pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret); /* keys starting with "kernel." are passed via cmdline */ From patchwork Wed Sep 15 00:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4765FC433EF for ; Wed, 15 Sep 2021 00:53:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D8B8C61242 for ; Wed, 15 Sep 2021 00:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D8B8C61242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7978E940008; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 746E16B0074; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 635F2940008; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 551F96B0073 for ; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1410782499B9 for ; Wed, 15 Sep 2021 00:53:34 +0000 (UTC) X-FDA: 78587984748.06.208755D Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id C3D523000103 for ; Wed, 15 Sep 2021 00:53:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C72D761165; Wed, 15 Sep 2021 00:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667213; bh=z+Rz9mifdit69o+uIbSikKcuPTSNShUmHrawtlDV4WI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GDzsdNsTDeveoDIbcZEYLKzJtN/0PoJtqtdsyBL0M8chUFYMumXnG5+nM2QgwDAhX uuVRNmUA/SbTPOOrDx1175Hx9PRJDNCzHrC/gvRNX8lvbs/ct0VCwbSS63EIybHUju TJGz5l79xcqMg8a2uTf8O+4hYqd8vTT5vQwPmXGuuQygQCdFuv39/W0q1wjkKv0a5o ojmJ6IJYf5u6gQrvUUb4aCbvh7Q7StuRlw5rk22DUoAiO44ruDzlkKKB+lnIVjFlhu Wn8KUcc0Cbh0DzymItHLsKaUiXdP6E1/THe3KynYMzzYBogMTtxgrh/XHPcOLilUe0 rpqFVbaz1REuw== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 4/5] bootconfig: Free copied bootconfig data after boot Date: Wed, 15 Sep 2021 09:53:30 +0900 Message-Id: <163166721027.510331.6820619440348067061.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C3D523000103 X-Stat-Signature: ea7636fc7d3c45rpzsptixadh4yx5u9f Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GDzsdNsT; spf=pass (imf09.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1631667213-571632 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: Free copied bootconfig data after booting kernel because that data will not be used anymore. commit 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") freed the bootconfig xbc_node array after booting kernel, but forgot to free the bootconfig data itself. This fixes that to free the bootconfig data too. Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") Signed-off-by: Masami Hiramatsu --- Changes in v2: - Split memblock leak fix because it fixes another commit. - Use memblock_free_ptr() --- init/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init/main.c b/init/main.c index 4f059fde1df0..0148152652e9 100644 --- a/init/main.c +++ b/init/main.c @@ -319,6 +319,8 @@ static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum) #ifdef CONFIG_BOOT_CONFIG static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata; +static void *init_xbc_data_copy __initdata; +static phys_addr_t init_xbc_data_size __initdata; #define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0) @@ -466,12 +468,17 @@ static void __init setup_boot_config(void) extra_command_line = xbc_make_cmdline("kernel"); /* Also, "init." keys are init arguments */ extra_init_args = xbc_make_cmdline("init"); + init_xbc_data_copy = copy; + init_xbc_data_size = size + 1; } return; } static void __init exit_boot_config(void) { + if (!init_xbc_data_copy) + return; + memblock_free_ptr(init_xbc_data_copy, init_xbc_data_size); xbc_destroy_all(); } From patchwork Wed Sep 15 00:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11A90C433F5 for ; Wed, 15 Sep 2021 00:53:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B39B761184 for ; Wed, 15 Sep 2021 00:53:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B39B761184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 54D9D940009; Tue, 14 Sep 2021 20:53:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD9F6B0074; Tue, 14 Sep 2021 20:53:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ECE7940009; Tue, 14 Sep 2021 20:53:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 317EC6B0073 for ; Tue, 14 Sep 2021 20:53:42 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DADD43949F for ; Wed, 15 Sep 2021 00:53:41 +0000 (UTC) X-FDA: 78587985042.09.9F9050F Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP id 9DADE10000A6 for ; Wed, 15 Sep 2021 00:53:41 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id BE6276103B; Wed, 15 Sep 2021 00:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667220; bh=QfAiGsW60lLRZ4WZ3voUQCHotfWarlUyocpqA9j3zHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjyDzkqNUP4Dpo0RbzbUhYtTFDIgmyJBQ8lmQsggtTEPYYmE8O5I++FysDZd/oa24 UfvE8wlpv8BOPrMAnYv9bUWaT6QAUWQahihDqZPD9EehDLeuRHOpqfc8ceRkqjygep XODdfm8SmtzqQvwp/bLcD+ZQl6Ve/jhfYmlHunUM9JUOaUVd4bDtL87hBJSHRskMgp FfIkqxSm63j2Eix7oM+J9NO+0YF2BgeGNUS7jXX6g970OKfg1fFz4dDqgGR+AOv7bb +1CuZgR+ujEt6Vahp5MN75C6soVVNAxX3N4VmTi5gZxnKnpUETHNYq30Coe+aaOFxA HxyLYiXznP/fA== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 5/5] tools/bootconfig: Define memblock_free_ptr() to fix build error Date: Wed, 15 Sep 2021 09:53:38 +0900 Message-Id: <163166721835.510331.4931010992364519157.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9DADE10000A6 X-Stat-Signature: xxxdrx7pd5wkot55hbopufwo3bjtzjfx Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZjyDzkqN; spf=pass (imf07.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1631667221-974170 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: Since commit 77e02cf57b6c ("memblock: introduce saner 'memblock_free_ptr()' interface") introduced memblock_free_ptr() to lib/bootconfig.c, bootconfig tool also has to define memblock_free_ptr() wrapper, and remove unused __pa() and memblock_free(). Fixes: 77e02cf57b6c ("memblock: introduce saner 'memblock_free_ptr()' interface") Signed-off-by: Masami Hiramatsu --- tools/bootconfig/include/linux/memblock.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/bootconfig/include/linux/memblock.h b/tools/bootconfig/include/linux/memblock.h index 7862f217d85d..f2e506f7d57f 100644 --- a/tools/bootconfig/include/linux/memblock.h +++ b/tools/bootconfig/include/linux/memblock.h @@ -4,9 +4,8 @@ #include -#define __pa(addr) (addr) #define SMP_CACHE_BYTES 0 #define memblock_alloc(size, align) malloc(size) -#define memblock_free(paddr, size) free(paddr) +#define memblock_free_ptr(paddr, size) free(paddr) #endif