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]
Date:   Tue, 19 May 2020 12:42:35 -0700
From:   Joe Perches <joe@...ches.com>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Chenggang Wang <wangchenggang@...o.com>,
        linux-kernel@...r.kernel.org
Cc:     Petr Mladek <pmladek@...e.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>
Subject: [RFC PATCH 2/2] init: Allow multi-line output of kernel command line

ARM may have its longest possible command line larger than the longest
possible printk.

If necessary, emit the commend line on multiple lines.

Signed-off-by: Joe Perches <joe@...ches.com>
---

compiled, untested

 init/main.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/init/main.c b/init/main.c
index b63a3c001ac4..b3ebbbc129ae 100644
--- a/init/main.c
+++ b/init/main.c
@@ -826,6 +826,34 @@ void __init __weak arch_call_rest_init(void)
 	rest_init();
 }
 
+static void __init print_cmdline(char *line)
+{
+#ifdef CONFIG_PRINTK
+	const char *prefix = "Kernel command line";
+	size_t len = strlen(line);
+
+	while (len > PRINTK_LOG_LINE_MAX) {
+		char *pos = line;
+		char *last_pos = pos + PRINTK_LOG_LINE_MAX - 1;
+		char saved_char;
+		/* Find last space char within the maximum line length */
+		while ((pos = memchr(pos, ' ', len - (pos - line))) &&
+		       (pos - line) < PRINTK_LOG_LINE_MAX - 1) {
+			last_pos = pos;
+		}
+		saved_char = line[last_pos - line];
+		line[last_pos - line] = 0;
+		pr_notice("%s: %s\n", prefix, line);
+		prefix = "Kernel command line (continued)";
+		line[last_pos - line] = saved_char;
+		len -= pos - line;
+		line += pos - line;
+	}
+
+	pr_notice("%s: %s\n", prefix, line);
+#endif
+}
+
 asmlinkage __visible void __init start_kernel(void)
 {
 	char *command_line;
@@ -859,7 +887,8 @@ asmlinkage __visible void __init start_kernel(void)
 	build_all_zonelists(NULL);
 	page_alloc_init();
 
-	pr_notice("Kernel command line: %s\n", saved_command_line);
+	print_cmdline(saved_command_line);
+
 	/* parameters may set static keys */
 	jump_label_init();
 	parse_early_param();
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ