From nobody Tue Sep 9 18:03:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07633C001B0 for ; Wed, 26 Jul 2023 14:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234172AbjGZOeA (ORCPT ); Wed, 26 Jul 2023 10:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbjGZOd5 (ORCPT ); Wed, 26 Jul 2023 10:33:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71240E78 for ; Wed, 26 Jul 2023 07:33:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 05F6261AF5 for ; Wed, 26 Jul 2023 14:33:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03551C433C8; Wed, 26 Jul 2023 14:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690382035; bh=yKI834690DMfFD3Ac39aSv3ombGoauP68gOWLlcu20s=; h=From:To:Cc:Subject:Date:From; b=XNg1U7w5Y5IoEainF926JUZdgDhOH2KC2ks7NYx3Ht3eEWO/YSwA+LWn9s4QJdYs2 nAS/tWayqxr9CUeHMlUYWe44DKWSXL64RbhSvfkmrZkhU9cm7SEWkQ61cF7BqIlRQh k8CTzF/BwopObku3vHmJ6RKqCM/AbSxphYOaVjJt0Fl6xWfnwCZo5Ue3geQYkohWa1 b/KmkF2vY1F+v07WsiBM1/f9EJbSnhthzCqHhAA7snCX4ZYAhrJ9moI+ksQMIC2Zfr 7x2HDxkOEXrkmh39WU4Tq1aNe79vHtNyg9YSNZ3kX3+ZT0FF3+8w5z8IDFVul7Maef 76iDM6Rf6eqiQ== From: Arnd Bergmann To: "Paul E. McKenney" Cc: Arnd Bergmann , Andrew Morton , Kees Cook , "Peter Zijlstra (Intel)" , Sami Tolvanen , Alexey Dobriyan , Masahiro Yamada , Josh Poimboeuf , "ndesaulniers@google.com" , linux-kernel@vger.kernel.org Subject: [PATCH] init: keep boot_command_line after init Date: Wed, 26 Jul 2023 16:33:21 +0200 Message-Id: <20230726143348.724611-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The boot command line is not available after the init section gets discarde= d, so adding a permanent reference to it causes a link time warning: WARNING: modpost: vmlinux: section mismatch in reference: cmdline_load_proc= _show+0x2 (section: .text) -> boot_command_line (section: .init.data) ERROR: modpost: Section mismatches detected. Set CONFIG_SECTION_MISMATCH_WARN_ONLY=3Dy to allow them. Change it to __ro_after_init to prevent it from getting freed. Fixes: cf9eca90a3397 ("fs/proc: Add /proc/cmdline_load for boot loader argu= ments") Signed-off-by: Arnd Bergmann Reviewed-by: Nick Desaulniers --- include/linux/init.h | 2 +- init/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index 9a5973324072b..4e97a7a29a4d7 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -143,7 +143,7 @@ struct file_system_type; =20 /* Defined in init/main.c */ extern int do_one_initcall(initcall_t fn); -extern char __initdata boot_command_line[]; +extern char boot_command_line[]; extern char *saved_command_line; extern unsigned int saved_command_line_len; extern unsigned int reset_devices; diff --git a/init/main.c b/init/main.c index c946ab87783a1..981170da0b1cd 100644 --- a/init/main.c +++ b/init/main.c @@ -135,7 +135,7 @@ EXPORT_SYMBOL(system_state); void (*__initdata late_time_init)(void); =20 /* Untouched command line saved by arch-specific code. */ -char __initdata boot_command_line[COMMAND_LINE_SIZE]; +char boot_command_line[COMMAND_LINE_SIZE] __ro_after_init; /* Untouched saved command line (eg. for /proc) */ char *saved_command_line __ro_after_init; unsigned int saved_command_line_len __ro_after_init; --=20 2.39.2