2023-10-05 17:23:01

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH bootconfig 0/3] Expose boot-loader kernel command-line arguments

Hello!

This series contains bootconfig updates that make the kernel command-line
arguments that came from the bootloader (excluding those from bootconfig)
visible as a comment in the existing /proc/bootconfig file. It also
updates documentation.

1. Update /proc/cmdline documentation to include boot config.

2. fs/proc: Add boot loader arguments as comment to /proc/bootconfig.

3. Add /proc/bootconfig to proc.rst.

Thanx, Paul

------------------------------------------------------------------------

Documentation/filesystems/proc.rst | 5 +++++
b/Documentation/filesystems/proc.rst | 3 ++-
b/fs/proc/bootconfig.c | 6 ++++++
3 files changed, 13 insertions(+), 1 deletion(-)


2023-10-05 17:24:12

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig

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/[email protected]/
Co-developed-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
---
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

2023-10-05 17:24:16

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config

Update the /proc/cmdline documentation to explicitly state that this
file provides kernel boot parameters obtained via boot config from the
kernel image as well as those supplied by the boot loader.

Signed-off-by: Paul E. McKenney <[email protected]>
Acked-by: Masami Hiramatsu (Google) <[email protected]>
Reviewed-by: Randy Dunlap <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Arnd Bergmann <[email protected]>
---
Documentation/filesystems/proc.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 2b59cff8be17..5703b0e87cbe 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -691,7 +691,8 @@ files are there, and which are missing.
apm Advanced power management info
buddyinfo Kernel memory allocator information (see text) (2.5)
bus Directory containing bus specific information
- cmdline Kernel command line
+ cmdline Kernel command line, both from bootloader and embedded
+ in the kernel image
cpuinfo Info about the CPU
devices Available devices (block and character)
dma Used DMS channels
--
2.40.1

2023-10-05 17:24:27

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH bootconfig 3/3] doc: Add /proc/bootconfig to proc.rst

Add /proc/bootconfig description to Documentation/filesystems/proc.rst.

Reported-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
Acked-by: Masami Hiramatsu (Google) <[email protected]>
---
Documentation/filesystems/proc.rst | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 5703b0e87cbe..a2c160f29632 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -689,6 +689,11 @@ files are there, and which are missing.
File Content
============ ===============================================================
apm Advanced power management info
+ bootconfig Kernel command line obtained from boot config,
+ and, if there were kernel parameters from the
+ boot loader, a "# Parameters from bootloader:"
+ line followed by a line containing those
+ parameters prefixed by "# ". (5.5)
buddyinfo Kernel memory allocator information (see text) (2.5)
bus Directory containing bus specific information
cmdline Kernel command line, both from bootloader and embedded
--
2.40.1

2023-10-06 09:01:55

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig

On Thu, 5 Oct 2023 10:17:46 -0700
"Paul E. McKenney" <[email protected]> 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.
> 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.

Thanks for update it.

This looks good to me.

Acked-by: Masami Hiramatsu (Google) <[email protected]>

Thank you!

>
> Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/
> Link: https://lore.kernel.org/all/[email protected]/
> Co-developed-by: Masami Hiramatsu <[email protected]>
> Signed-off-by: Masami Hiramatsu <[email protected]>
> Signed-off-by: Paul E. McKenney <[email protected]>
> Cc: Linus Torvalds <[email protected]>
> Cc: Stephen Rothwell <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Nick Desaulniers <[email protected]>
> Cc: Alexey Dobriyan <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Kees Cook <[email protected]>
> Cc: <[email protected]>
> Cc: <[email protected]>
> ---
> 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
>


--
Masami Hiramatsu (Google) <[email protected]>

2023-10-06 16:52:47

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig

On Fri, Oct 06, 2023 at 05:59:48PM +0900, Masami Hiramatsu wrote:
> On Thu, 5 Oct 2023 10:17:46 -0700
> "Paul E. McKenney" <[email protected]> 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.
> > 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.
>
> Thanks for update it.
>
> This looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <[email protected]>
>
> Thank you!

And thank you! I take this as meaning that I should push these three
commits for the upcoming v6.7 merge window. Please let me know if I
should be doing something else.

Thanx, Paul

> > Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/
> > Link: https://lore.kernel.org/all/[email protected]/
> > Co-developed-by: Masami Hiramatsu <[email protected]>
> > Signed-off-by: Masami Hiramatsu <[email protected]>
> > Signed-off-by: Paul E. McKenney <[email protected]>
> > Cc: Linus Torvalds <[email protected]>
> > Cc: Stephen Rothwell <[email protected]>
> > Cc: Arnd Bergmann <[email protected]>
> > Cc: Nick Desaulniers <[email protected]>
> > Cc: Alexey Dobriyan <[email protected]>
> > Cc: Andrew Morton <[email protected]>
> > Cc: Kees Cook <[email protected]>
> > Cc: <[email protected]>
> > Cc: <[email protected]>
> > ---
> > 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
> >
>
>
> --
> Masami Hiramatsu (Google) <[email protected]>

2023-10-07 01:42:39

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig

On Fri, 6 Oct 2023 09:52:30 -0700
"Paul E. McKenney" <[email protected]> wrote:

> On Fri, Oct 06, 2023 at 05:59:48PM +0900, Masami Hiramatsu wrote:
> > On Thu, 5 Oct 2023 10:17:46 -0700
> > "Paul E. McKenney" <[email protected]> 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.
> > > 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.
> >
> > Thanks for update it.
> >
> > This looks good to me.
> >
> > Acked-by: Masami Hiramatsu (Google) <[email protected]>
> >
> > Thank you!
>
> And thank you! I take this as meaning that I should push these three
> commits for the upcoming v6.7 merge window. Please let me know if I
> should be doing something else.

I have my bootconfig branch, so I think I should pick this and push it
to the next window. Does it work?

Thank you,

>
> Thanx, Paul
>
> > > Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/
> > > Link: https://lore.kernel.org/all/[email protected]/
> > > Co-developed-by: Masami Hiramatsu <[email protected]>
> > > Signed-off-by: Masami Hiramatsu <[email protected]>
> > > Signed-off-by: Paul E. McKenney <[email protected]>
> > > Cc: Linus Torvalds <[email protected]>
> > > Cc: Stephen Rothwell <[email protected]>
> > > Cc: Arnd Bergmann <[email protected]>
> > > Cc: Nick Desaulniers <[email protected]>
> > > Cc: Alexey Dobriyan <[email protected]>
> > > Cc: Andrew Morton <[email protected]>
> > > Cc: Kees Cook <[email protected]>
> > > Cc: <[email protected]>
> > > Cc: <[email protected]>
> > > ---
> > > 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
> > >
> >
> >
> > --
> > Masami Hiramatsu (Google) <[email protected]>


--
Masami Hiramatsu (Google) <[email protected]>

2023-10-07 01:49:26

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH bootconfig 1/3] doc: Update /proc/cmdline documentation to include boot config

On Thu, 5 Oct 2023 10:17:45 -0700
"Paul E. McKenney" <[email protected]> wrote:

> Update the /proc/cmdline documentation to explicitly state that this
> file provides kernel boot parameters obtained via boot config from the
> kernel image as well as those supplied by the boot loader.
>
> Signed-off-by: Paul E. McKenney <[email protected]>
> Acked-by: Masami Hiramatsu (Google) <[email protected]>
> Reviewed-by: Randy Dunlap <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Stephen Rothwell <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> ---
> Documentation/filesystems/proc.rst | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
> index 2b59cff8be17..5703b0e87cbe 100644
> --- a/Documentation/filesystems/proc.rst
> +++ b/Documentation/filesystems/proc.rst
> @@ -691,7 +691,8 @@ files are there, and which are missing.
> apm Advanced power management info
> buddyinfo Kernel memory allocator information (see text) (2.5)
> bus Directory containing bus specific information
> - cmdline Kernel command line
> + cmdline Kernel command line, both from bootloader and embedded
> + in the kernel image

BTW, as same as the other lines, I changed this to white spaces instead
of tabs.

> cpuinfo Info about the CPU
> devices Available devices (block and character)
> dma Used DMS channels
> --
> 2.40.1
>


--
Masami Hiramatsu (Google) <[email protected]>

2023-10-07 01:52:10

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH bootconfig 3/3] doc: Add /proc/bootconfig to proc.rst

On Thu, 5 Oct 2023 10:17:47 -0700
"Paul E. McKenney" <[email protected]> wrote:

> Add /proc/bootconfig description to Documentation/filesystems/proc.rst.
>
> Reported-by: Masami Hiramatsu <[email protected]>
> Signed-off-by: Paul E. McKenney <[email protected]>
> Acked-by: Masami Hiramatsu (Google) <[email protected]>
> ---
> Documentation/filesystems/proc.rst | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
> index 5703b0e87cbe..a2c160f29632 100644
> --- a/Documentation/filesystems/proc.rst
> +++ b/Documentation/filesystems/proc.rst
> @@ -689,6 +689,11 @@ files are there, and which are missing.
> File Content
> ============ ===============================================================
> apm Advanced power management info
> + bootconfig Kernel command line obtained from boot config,
> + and, if there were kernel parameters from the
> + boot loader, a "# Parameters from bootloader:"
> + line followed by a line containing those
> + parameters prefixed by "# ". (5.5)

Ditto. Curiously, in this part of the document, the tail spaces until "(5.5)"
are using tabs, but the head spaces are using whitespaces. So updated it.
I noticed that a warning message when I imported it to my bootconfig/for-next
branch.

Thank you,

> buddyinfo Kernel memory allocator information (see text) (2.5)
> bus Directory containing bus specific information
> cmdline Kernel command line, both from bootloader and embedded
> --
> 2.40.1
>


--
Masami Hiramatsu (Google) <[email protected]>

2023-10-07 03:43:44

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH bootconfig 2/3] fs/proc: Add boot loader arguments as comment to /proc/bootconfig

On Sat, Oct 07, 2023 at 10:42:09AM +0900, Masami Hiramatsu wrote:
> On Fri, 6 Oct 2023 09:52:30 -0700
> "Paul E. McKenney" <[email protected]> wrote:
>
> > On Fri, Oct 06, 2023 at 05:59:48PM +0900, Masami Hiramatsu wrote:
> > > On Thu, 5 Oct 2023 10:17:46 -0700
> > > "Paul E. McKenney" <[email protected]> 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.
> > > > 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.
> > >
> > > Thanks for update it.
> > >
> > > This looks good to me.
> > >
> > > Acked-by: Masami Hiramatsu (Google) <[email protected]>
> > >
> > > Thank you!
> >
> > And thank you! I take this as meaning that I should push these three
> > commits for the upcoming v6.7 merge window. Please let me know if I
> > should be doing something else.
>
> I have my bootconfig branch, so I think I should pick this and push it
> to the next window. Does it work?

That works for me, and thank you!

(And thank you for taking and fixing my whitespace errors in the
other two patches!)

Thanx, Paul

> > > > Link: https://lore.kernel.org/all/CAHk-=wjpVAW3iRq_bfKnVfs0ZtASh_aT67bQBG11b4W6niYVUw@mail.gmail.com/
> > > > Link: https://lore.kernel.org/all/[email protected]/
> > > > Co-developed-by: Masami Hiramatsu <[email protected]>
> > > > Signed-off-by: Masami Hiramatsu <[email protected]>
> > > > Signed-off-by: Paul E. McKenney <[email protected]>
> > > > Cc: Linus Torvalds <[email protected]>
> > > > Cc: Stephen Rothwell <[email protected]>
> > > > Cc: Arnd Bergmann <[email protected]>
> > > > Cc: Nick Desaulniers <[email protected]>
> > > > Cc: Alexey Dobriyan <[email protected]>
> > > > Cc: Andrew Morton <[email protected]>
> > > > Cc: Kees Cook <[email protected]>
> > > > Cc: <[email protected]>
> > > > Cc: <[email protected]>
> > > > ---
> > > > 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
> > > >
> > >
> > >
> > > --
> > > Masami Hiramatsu (Google) <[email protected]>
>
>
> --
> Masami Hiramatsu (Google) <[email protected]>