From: Chris Novakovic <chris@chrisn.me.uk>
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Cc: Chris Novakovic <chris@chrisn.me.uk>
Subject: [PATCH 6/8] ipconfig: Correctly initialise ic_nameservers
Date: Sat, 7 Apr 2018 05:09:01 +0100 [thread overview]
Message-ID: <20180407040903.8997-7-chris@chrisn.me.uk> (raw)
In-Reply-To: <20180407040903.8997-1-chris@chrisn.me.uk>
ic_nameservers, which stores the list of name servers discovered by
ipconfig, is initialised (i.e. has all of its elements set to NONE, or
0xffffffff) by ic_nameservers_predef() in the following scenarios:
- before the "ip=" and "nfsaddrs=" kernel command line parameters are
parsed (in ip_auto_config_setup());
- before autoconfiguring via DHCP or BOOTP (in ic_bootp_init()), in
order to clear any values that may have been set after parsing "ip="
or "nfsaddrs=" and are no longer needed.
This means that ic_nameservers_predef() is not called when neither "ip="
nor "nfsaddrs=" is specified on the kernel command line. In this
scenario, every element in ic_nameservers remains set to 0x00000000,
which is indistinguishable from ANY and causes pnp_seq_show() to write
the following (bogus) information to /proc/net/pnp:
#MANUAL
nameserver 0.0.0.0
nameserver 0.0.0.0
nameserver 0.0.0.0
This is potentially problematic for systems that blindly link
/etc/resolv.conf to /proc/net/pnp.
Ensure that ic_nameservers is also initialised when neither "ip=" nor
"nfsaddrs=" is specified by calling ic_nameservers_predef() in
ip_auto_config(), but only when ip_auto_config_setup() was not called
earlier. This causes the following to be written to /proc/net/pnp, and
is consistent with what gets written when ipconfig is configured
manually but no name servers are specified on the kernel command line:
#MANUAL
Signed-off-by: Chris Novakovic <chris@chrisn.me.uk>
---
net/ipv4/ipconfig.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 0f460d6d3cce..e11dfd29a929 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -750,6 +750,11 @@ static void __init ic_bootp_init_ext(u8 *e)
*/
static inline void __init ic_bootp_init(void)
{
+ /* Re-initialise all name servers to NONE, in case any were set via the
+ * "ip=" or "nfsaddrs=" kernel command line parameters: any IP addresses
+ * specified there will already have been decoded but are no longer
+ * needed
+ */
ic_nameservers_predef();
dev_add_pack(&bootp_packet_type);
@@ -1370,6 +1375,13 @@ static int __init ip_auto_config(void)
int err;
unsigned int i;
+ /* Initialise all name servers to NONE (but only if the "ip=" or
+ * "nfsaddrs=" kernel command line parameters weren't decoded, otherwise
+ * we'll overwrite the IP addresses specified there)
+ */
+ if (ic_set_manually == 0)
+ ic_nameservers_predef();
+
#ifdef CONFIG_PROC_FS
proc_create("pnp", 0444, init_net.proc_net, &pnp_seq_fops);
#endif /* CONFIG_PROC_FS */
@@ -1593,6 +1605,7 @@ static int __init ip_auto_config_setup(char *addrs)
return 1;
}
+ /* Initialise all name servers to NONE */
ic_nameservers_predef();
/* Parse string for static IP assignment. */
--
2.14.1
next prev parent reply other threads:[~2018-04-07 4:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-07 4:08 [PATCH 0/8] ipconfig: NTP server support, bug fixes, documentation improvements Chris Novakovic
2018-04-07 4:08 ` [PATCH 1/8] ipconfig: Document setting of NIS domain name Chris Novakovic
2018-04-07 4:08 ` [PATCH 2/8] ipconfig: Tidy up reporting of name servers Chris Novakovic
2018-04-07 4:08 ` [PATCH 3/8] ipconfig: BOOTP: Don't request IEN-116 " Chris Novakovic
2018-04-07 4:08 ` [PATCH 4/8] ipconfig: BOOTP: Request CONF_NAMESERVERS_MAX " Chris Novakovic
2018-04-07 4:09 ` [PATCH 5/8] ipconfig: Document /proc/net/pnp Chris Novakovic
2018-04-07 4:09 ` Chris Novakovic [this message]
2018-04-07 4:09 ` [PATCH 7/8] ipconfig: Write NTP server IPs to /proc/net/ntp Chris Novakovic
2018-04-07 15:25 ` Chris Novakovic
2018-04-07 15:28 ` [PATCH v2 " Chris Novakovic
2018-04-07 4:09 ` [PATCH 8/8] CREDITS: Add Chris Novakovic Chris Novakovic
2018-04-07 16:29 ` [PATCH 0/8] ipconfig: NTP server support, bug fixes, documentation improvements David Miller
2018-04-07 17:49 ` Chris Novakovic
-- strict thread matches above, loose matches on Subject: below --
2018-04-17 20:58 Chris Novakovic
2018-04-17 20:58 ` [PATCH 6/8] ipconfig: Correctly initialise ic_nameservers Chris Novakovic
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=20180407040903.8997-7-chris@chrisn.me.uk \
--to=chris@chrisn.me.uk \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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).