The patch titled Subject: init-add-hostname-kernel-parameter-v2 has been added to the -mm mm-nonmm-unstable branch. Its filename is init-add-hostname-kernel-parameter-v2.patch This patch should soon appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Dan Moulding <dmoulding@xxxxxx> Subject: init-add-hostname-kernel-parameter-v2 Link: https://lkml.kernel.org/r/20220506060310.7495-2-dmoulding@xxxxxx Signed-off-by: Dan Moulding <dmoulding@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/admin-guide/kernel-parameters.txt | 4 ++-- init/version.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) --- a/Documentation/admin-guide/kernel-parameters.txt~init-add-hostname-kernel-parameter-v2 +++ a/Documentation/admin-guide/kernel-parameters.txt @@ -1615,6 +1615,8 @@ Valid parameters: "on", "off" Default: "on" + hlt [BUGS=ARM,SH] + hostname= [KNL] Set the hostname (aka UTS nodename). Format: <string> This allows setting the system's hostname during early @@ -1628,8 +1630,6 @@ not exceed the maximum allowed hostname length (usually 64 characters) and will be truncated otherwise. - hlt [BUGS=ARM,SH] - hpet= [X86-32,HPET] option to control HPET usage Format: { enable (default) | disable | force | verbose } --- a/init/version.c~init-add-hostname-kernel-parameter-v2 +++ a/init/version.c @@ -41,12 +41,12 @@ static int __init early_hostname(char *a { size_t bufsize = sizeof(init_uts_ns.name.nodename); size_t maxlen = bufsize - 1; + size_t arglen; - strncpy(init_uts_ns.name.nodename, arg, bufsize); - if (strlen(arg) > maxlen) { + arglen = strlcpy(init_uts_ns.name.nodename, arg, bufsize); + if (arglen > maxlen) { pr_warn("hostname parameter exceeds %zd characters and will be truncated", maxlen); - init_uts_ns.name.nodename[maxlen] = '\0'; } return 0; } _ Patches currently in -mm which might be from dmoulding@xxxxxx are init-add-hostname-kernel-parameter.patch init-add-hostname-kernel-parameter-v2.patch