Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp252827rwb; Fri, 4 Aug 2023 12:07:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMxTIh9WMYIRHEqh16yx3C829QJ5u3JkVX1DzwebuubrXCnM77JsWNLi98soWEtVj+RMHx X-Received: by 2002:a17:902:ba8d:b0:1b6:649b:92cc with SMTP id k13-20020a170902ba8d00b001b6649b92ccmr2305278pls.69.1691176033965; Fri, 04 Aug 2023 12:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176033; cv=none; d=google.com; s=arc-20160816; b=D6AeL0u7/NmaadG08bvp61E5fIeZzqmWxG8gbLUEiHm3lKbublNAiTwmub3JV7LTHQ DVBasJX/9lRqKAKm7A642zrfQtb4PG+5zCKgcoJX3rwjU/KqlFZl5lVNDJ8V/BCg8EOb i5y6Hp7zelzzVQzdA4R5ChTSTGmVwPJeCuDB21xnSwApaxwn+teUuTDxYfT0EZ0HuwkY BQiZb9yEYEMyIKRFhnYYOx6NUPcCppB1OsSzMClNa53bevs3m2JoTAlJiglIy1yysp/G yi4ANAeFtRyY34yiGpkznDcqT6cESZyfjVwVQuTf+KmpwF75e1TCb/S/SZe2/dzgjAjT 2IHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fkna6gF7xfiIv/ekAanUz0DmTu9Ddqz9dXm8WgfXwE8=; fh=4tSvR71olhj1p5H1QMAZuOiFDdwKSZoMYuPwp/uivDo=; b=SMY3tOF5fWLXen2M+48cC4HnRK2/6BHalMco6sGGs1+/Xu1OOrt5N0tIbq6jS61qOh 2EJWMWZPiQgvEjFPibWTa/6oEGZ6hVXXaP5kU89e8WuDDu0XCtPubMOFULa1GcGzjPkR d2XqDkgobueT5xD8Q52YRouUhEjomeI+f7J95sNdC3kLFsWxJ+deKouT6HxZJsJRsjU9 TLh4j4Xq1qmEVyeVCmQki0LA8jbQFNEWdxcPw+d+jG+HO9puignikohZotcGpbhpsCE0 QoYWLI66BPud9mKDBOCA17keObTWbudTKUqdsQUXgoC3SlKlmR7lxZKPUUWUsQaUhdGF foxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bMcMiiJy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a170903231000b001b3d6d125f9si521847plh.524.2023.08.04.12.06.49; Fri, 04 Aug 2023 12:07:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bMcMiiJy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbjHDSns (ORCPT + 99 others); Fri, 4 Aug 2023 14:43:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjHDSnq (ORCPT ); Fri, 4 Aug 2023 14:43:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1D546B2; Fri, 4 Aug 2023 11:43:43 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83177620F5; Fri, 4 Aug 2023 18:43:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D00C9C433C8; Fri, 4 Aug 2023 18:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691174622; bh=tE3RdQBl89VvXPLghQzSjkSIzG6lje0YiOUVHgPhae8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=bMcMiiJyBvBE4GGuodwYhv/flRnIOsbx/RH1ymw8R9a33abKVAoZIf5hsunloPzrV 9/2NQ/x1zar/cRHPi3SzXn3yFElj680lzNBMNGHPEqt0iHxMd069uJcIcSj0WpcaHw ee7c56iCxJaJtJjq3FY5+zrGB+HgequxQXmOzjesCvTOYGGdYkBzEp7RHTNxCycS9q uJ8PXfK+WWr5fIwpXEzWBRXCxYHZcj/R0WnqBox6QO8YS+qXMaraclQhzUJge7vtAp oUrn9Cjh7hnTClPlcgO7hxj2fH9+DGXYvV1JH2oEIndlBhc6Tz/KEdkcUfnR68xuM+ mVxXDSe8BJ7qA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 619CCCE0591; Fri, 4 Aug 2023 11:43:42 -0700 (PDT) Date: Fri, 4 Aug 2023 11:43:42 -0700 From: "Paul E. McKenney" To: Alexey Dobriyan Cc: akpm@linux-foundation.org, mhiramat@kernel.org, arnd@kernel.org, ndesaulniers@google.com, sfr@canb.auug.org.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments Message-ID: Reply-To: paulmck@kernel.org References: <197cba95-3989-4d2f-a9f1-8b192ad08c49@paulmck-laptop> <20230728033701.817094-1-paulmck@kernel.org> <9a42de2a-7d9f-4be3-b6c8-9f3e8a092c4d@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a42de2a-7d9f-4be3-b6c8-9f3e8a092c4d@paulmck-laptop> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 On Fri, Aug 04, 2023 at 10:36:17AM -0700, Paul E. McKenney wrote: > On Fri, Aug 04, 2023 at 08:23:20PM +0300, Alexey Dobriyan wrote: > > On Thu, Jul 27, 2023 at 08:37:00PM -0700, Paul E. McKenney wrote: > > > 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. > > > > > > Therefore, provide a /proc/cmdline_load file that shows only those kernel > > > boot parameters supplied by the boot loader. > > > > > +static int cmdline_load_proc_show(struct seq_file *m, void *v) > > > +{ > > > + seq_puts(m, boot_command_line); > > > + seq_putc(m, '\n'); > > > + return 0; > > > +} > > > + > > > static int __init proc_cmdline_init(void) > > > { > > > struct proc_dir_entry *pde; > > > @@ -19,6 +27,11 @@ static int __init proc_cmdline_init(void) > > > pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show); > > > pde_make_permanent(pde); > > > pde->size = saved_command_line_len + 1; > > > + if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) { > > > + pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show); > > > + pde_make_permanent(pde); > > > + pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1; > > > + } > > > > Please add it as separate fs/proc/cmdline_load.c file so that name of > > the file matches name of the /proc file. > > Thank you, will do! And here is an untested sneak preview, which I will fold into the original after testing. Thoughts? Thanx, Paul ------------------------------------------------------------------------ diff --git a/fs/proc/Makefile b/fs/proc/Makefile index bd08616ed8ba..094f3102eb9f 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile @@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE) += vmcore.o proc-$(CONFIG_PRINTK) += kmsg.o proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o proc-$(CONFIG_BOOT_CONFIG) += bootconfig.o +proc-$(CONFIG_BOOT_CONFIG_FORCE) += cmdline_load.o diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c index 1d0ef9d2949d..082def2c1cc6 100644 --- a/fs/proc/cmdline.c +++ b/fs/proc/cmdline.c @@ -13,13 +13,6 @@ static int cmdline_proc_show(struct seq_file *m, void *v) return 0; } -static int cmdline_load_proc_show(struct seq_file *m, void *v) -{ - seq_puts(m, boot_command_line); - seq_putc(m, '\n'); - return 0; -} - static int __init proc_cmdline_init(void) { struct proc_dir_entry *pde; @@ -27,11 +20,6 @@ static int __init proc_cmdline_init(void) pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show); pde_make_permanent(pde); pde->size = saved_command_line_len + 1; - if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) { - pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show); - pde_make_permanent(pde); - pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1; - } return 0; } fs_initcall(proc_cmdline_init); diff --git a/fs/proc/cmdline_load.c b/fs/proc/cmdline_load.c new file mode 100644 index 000000000000..e3dccb3441ce --- /dev/null +++ b/fs/proc/cmdline_load.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include "internal.h" + +static int cmdline_load_proc_show(struct seq_file *m, void *v) +{ + seq_puts(m, boot_command_line); + seq_putc(m, '\n'); + return 0; +} + +static int __init proc_cmdline_load_init(void) +{ + struct proc_dir_entry *pde; + + pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show); + pde_make_permanent(pde); + pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1; + return 0; +} +fs_initcall(proc_cmdline_load_init);