Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp448627rdb; Thu, 5 Oct 2023 10:24:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1wmdUpyhZTWzYKaGZwNJAUpLfE4pc/eL9jGqXp7dgViDAyeGV0o1VRruIdGK2AQMMznlr X-Received: by 2002:a05:6a00:3993:b0:68f:cc47:fcc8 with SMTP id fi19-20020a056a00399300b0068fcc47fcc8mr5853238pfb.14.1696526652196; Thu, 05 Oct 2023 10:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696526652; cv=none; d=google.com; s=arc-20160816; b=uAosgCZL+t1GvJJupsI0iSVDlo+hYq5vKD2C0pgaEuIdMNfwwL/io3/PRARA11Z5Tq 29u4tP3I4/4Ql0byvD+6r4exwYnYstYL0xsQa38PyOIJdaVuPIMtiSAS48c1boedwT+D /niB6immQ8l4ybfNQIUD/gP8etDxOuj8K/gEvBkn40r4ZvbDtzhOfccBl2evzPwrw+Z6 fN6KNoezSXZUaXXF3ggRQ92Q1U8NCP8DnVEDYAYvB1mo2KH0NY5NU1mplyik5hT92/hY 35I+4/mtkLGZsZBDw1sja8+OYQSLUr19He7SeTWxXBeNCjbb8aYl87iEIFixIfogkO18 Se2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+FQS+2S9jhpADvkKOA62oi1uta2UWuhIV2kcg7r8yPw=; fh=L6JXhx3Rs1cDK256tTLM7ULwFG3ewp48JMYDpLQ62cc=; b=E+e/tWT4/P4722EQt7OJgbj3nzqcEzxQODbkTXh6bJA0+2adeXt72nQhNnC/I3hqTQ FnCG5FzSw8AeSmmYh0ty9LhP6PY637SpBUf+E1hWGS6KNmgZOSWG8e8pKFuGoLO45IMf dVxFZ//zbhIWN0ot2qxjxSuyGMZixBzJynU1Sm/LZqJYGEe6S/FC1M+K0A0u5J4oKz4e RjoBiC5zjFkWyiVjM4TNIG9aTWIbK9NzKQu7HCPq3RHoIB3TUDSaws2KRdbZBjWkYqoY 0JwjP54RgrpHSV+akQoujkAr1SlwBrMt6rThRUthG7sfWf1iDiQ3ORFhN3nO/wQ0pTEp Y7xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ljD0DSVX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h3-20020a656383000000b00565f0e9cfbbsi1823081pgv.382.2023.10.05.10.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ljD0DSVX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EAEBD8345280; Thu, 5 Oct 2023 10:24:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbjJERYF (ORCPT + 99 others); Thu, 5 Oct 2023 13:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbjJERXe (ORCPT ); Thu, 5 Oct 2023 13:23:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7BD33C27; Thu, 5 Oct 2023 10:17:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A67C433C7; Thu, 5 Oct 2023 17:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696526269; bh=o5L4igQZuUyyRkvZWeW6hIphjuPRgbdBnW7gTpA7Zqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljD0DSVXW7mrLs6rk+uo3OA3n8H7FoAXevG0rpTNVXlO2DhM+97akz/db9F7eliN5 SNbIT+B6xWAsEWFkyhHl9KEp9sDqDYd3nOR1FdJrXGba22PQ0OtrtztDB0xiLMUv4U NsIIAYqd5gIEja/x0tSYJgWFIS1sFMR4e5JhWh+kFR6GKb4Z4eU3efb+QA+VxubfD5 iJlmKXTYybduRDmv5K4UakHiSKx5UD2e7jPt8calVUcE8g2+UF9dQYAPuDmVzB9mKK RbgR4Q1HEngsKrSmb1wyPZLhT7YcBmnLC83OK62ejaUH/O5hGMEiPr7lL94GLALGEr 73I98sKn9MlgQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 167D2CE0975; Thu, 5 Oct 2023 10:17:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Jonathan Corbet , "Masami Hiramatsu (Google)" , "Paul E. McKenney" , Linus Torvalds , Stephen Rothwell , Arnd Bergmann , Nick Desaulniers , Alexey Dobriyan , Andrew Morton , Kees Cook , linux-trace-kernel@vger.kernel.org Subject: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig Date: Thu, 5 Oct 2023 10:17:46 -0700 Message-Id: <20231005171747.541123-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <6ea609a4-12e3-4266-8816-b9fca1f1f21c@paulmck-laptop> References: <6ea609a4-12e3-4266-8816-b9fca1f1f21c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 10:24:11 -0700 (PDT) In kernels built with CONFIG_BOOT_CONFIG_FORCE=y, /proc/cmdline will show all kernel boot parameters, both those supplied by the boot loader and those embedded in the kernel image. This works well for those who just want to see all of the kernel boot parameters, but is not helpful to those who need to see only those parameters supplied by the boot loader. This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources. It is also useful when booting the next kernel via kexec(), in which case it is necessary to supply only those kernel command-line arguments from the boot loader, and most definitely not those that were embedded into the current kernel. Therefore, add comments to /proc/bootconfig of the form: # Parameters from bootloader: # root=UUID=ac0f0548-a69d-43ca-a06b-7db01bcbd5ad ro quiet ... The second added line shows only those kernel boot parameters supplied by the boot loader. Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/ Link: https://lore.kernel.org/all/20230731233130.424913-1-paulmck@kernel.org/ Co-developed-by: Masami Hiramatsu Signed-off-by: Masami Hiramatsu Signed-off-by: Paul E. McKenney Cc: Linus Torvalds Cc: Stephen Rothwell Cc: Arnd Bergmann Cc: Nick Desaulniers Cc: Alexey Dobriyan Cc: Andrew Morton Cc: Kees Cook Cc: Cc: --- fs/proc/bootconfig.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c index 2e244ada1f97..902b326e1e56 100644 --- a/fs/proc/bootconfig.c +++ b/fs/proc/bootconfig.c @@ -62,6 +62,12 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) break; dst += ret; } + if (ret >= 0 && boot_command_line[0]) { + ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n", + boot_command_line); + if (ret > 0) + dst += ret; + } } out: kfree(key); -- 2.40.1