lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e0a1a4b6-7339-4fb9-aaad-3a3390a76491@paulmck-laptop>
Date:   Fri, 4 Aug 2023 11:43:42 -0700
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Alexey Dobriyan <adobriyan@...il.com>
Cc:     akpm@...ux-foundation.org, mhiramat@...nel.org, arnd@...nel.org,
        ndesaulniers@...gle.com, sfr@...b.auug.org.au,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-team@...a.com
Subject: Re: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for
 boot loader arguments

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 <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ