From: Dan Moulding <dmoulding@me.com>
To: linux-kernel@vger.kernel.org
Cc: linux-doc@vger.kernel.org, tglx@linutronix.de,
akpm@linux-foundation.org, corbet@lwn.net,
Dan Moulding <dmoulding@me.com>
Subject: [PATCH 0/1] Allow setting hostname before userspace starts
Date: Thu, 5 May 2022 12:06:50 -0600 [thread overview]
Message-ID: <20220505180651.22849-1-dmoulding@me.com> (raw)
Some userspace processes may rely on gethostname to always return the
correct machine name. However, the only way that the hostname may be
set is by some other userspace process calling sethostname
first. During boot, if a process that depends on gethostname runs
before sethostname has been called, then the process that called
gethostname is going to get an incorrect result.
A real-world case where this comes up is with mdadm, which if
gethostname returns the wrong name, can cause local md-raid arrays to
appear to be foreign arrays. This can alter how mdadm assembles the
array, or can even cause array assembly to fail. I imagine there are
probbaly other real-world cases where undesirable behavior results when
the hostname is not set early enough.
I'm proposing adding the option to set the hostname from a kernel
parameter, so that the correct host name can be guaranteed to be set
before any userspace process can call gethostname.
I can imagine an even better way to do this would be to have the
hostname written to some non-volatile storage (like a firmware NVRAM
variable or such), which the kernel could read out during early
boot. But, alas, such designs require hardware support, standards, and
cooperation. This proposal is an alternative that can provide a simple
and immediate solution.
I'm sending this to linux-kernel since I don't see any list that's a
better fit. If there is any other I should send to instead, please let
me know. (linux-doc also included since kernel-parameters.txt is
touched).
Thank you for consideration,
-- Dan
Dan Moulding (1):
init: Add "hostname" kernel parameter
Documentation/admin-guide/kernel-parameters.txt | 13 +++++++++++++
init/version.c | 17 +++++++++++++++++
2 files changed, 30 insertions(+)
--
2.35.1
next reply other threads:[~2022-05-05 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 18:06 Dan Moulding [this message]
2022-05-05 18:06 ` [PATCH 1/1] init: Add "hostname" kernel parameter Dan Moulding
2022-05-06 0:51 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220505180651.22849-1-dmoulding@me.com \
--to=dmoulding@me.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).