Skip to content

Commit 717c7c8

Browse files
paulmckrcumhiramat
authored andcommitted
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/[email protected]/ 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: 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]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent 1c20c65 commit 717c7c8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/proc/bootconfig.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
6262
break;
6363
dst += ret;
6464
}
65+
if (ret >= 0 && boot_command_line[0]) {
66+
ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n",
67+
boot_command_line);
68+
if (ret > 0)
69+
dst += ret;
70+
}
6571
}
6672
out:
6773
kfree(key);

0 commit comments

Comments
 (0)