* [PATCH] init: Fix early boot crash with bare hostname parameter
@ 2026-08-26 10:09 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-08-26 10:09 UTC (permalink / raw)
To: Andrew Morton, Dan Moulding; +Cc: Thorsten Blum, linux-kernel
When a bare hostname parameter is specified on the kernel command line
without the '=' separator, early parameter parsing passes NULL to
early_hostname(), which dereferences it in strscpy() and can crash the
system during early boot.
Reject NULL values in early_hostname() and return -EINVAL instead.
Fixes: 5a704629f2c1 ("init: add "hostname" kernel parameter")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
init/version.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/init/version.c b/init/version.c
index 94c96f6fbfe6..0bd5c45aabc4 100644
--- a/init/version.c
+++ b/init/version.c
@@ -23,6 +23,9 @@ static int __init early_hostname(char *arg)
size_t maxlen = bufsize - 1;
ssize_t arglen;
+ if (!arg)
+ return -EINVAL;
+
arglen = strscpy(init_uts_ns.name.nodename, arg, bufsize);
if (arglen < 0) {
pr_warn("hostname parameter exceeds %zd characters and will be truncated",
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-26 10:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 10:09 [PATCH] init: Fix early boot crash with bare hostname parameter Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox