Patchwork ipconfig: stop ip-config if disabled method directed

login
register
mail settings
Submitter Takashi Yoshii
Date April 10, 2013, 7:23 a.m.
Message ID <5165138A.7070006@renesas.com>
Download mbox | patch
Permalink /patch/235320/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Takashi Yoshii - April 10, 2013, 7:23 a.m.
Hi,

Looks insignificant, but a misusage of kernel level auto configuration
results in an invalid ipv4 address set.
That is a kind of corner case, but I think it is be better sanitizing
 the input a bit more for our simple in_aton().
--

CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=n
Command line: ip=dhcp
result in false ip address 62.0.0.0 set.

If directed autoconf method is not compiled into the kernel,
ip-config should be terminated.

Signed-off-by: Takashi Yoshii <takashi.yoshii.zj@renesas.com>
---
 net/ipv4/ipconfig.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
David Miller - April 11, 2013, 3:19 a.m.
From: Takashi Yoshii <takashi.yoshii.zj@renesas.com>
Date: Wed, 10 Apr 2013 16:23:54 +0900

> Looks insignificant, but a misusage of kernel level auto configuration
> results in an invalid ipv4 address set.
> That is a kind of corner case, but I think it is be better sanitizing
>  the input a bit more for our simple in_aton().
> --
> 
> CONFIG_IP_PNP=y
> CONFIG_IP_PNP_DHCP=n
> Command line: ip=dhcp
> result in false ip address 62.0.0.0 set.
> 
> If directed autoconf method is not compiled into the kernel,
> ip-config should be terminated.
> 
> Signed-off-by: Takashi Yoshii <takashi.yoshii.zj@renesas.com>

This is a poor submission.

When you put _before_ the "--" is the commit message, and the
text afterwards will be removed and not considered as part of
the commit message.

Secondly, put this logic into ic_proto_name() so we don't duplicate
all of these string comparisons.

Thirdly, consider simply removing all of these silly Kconfig
options, they seem rediculous.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index bf6c5cf..6401aac 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -1586,6 +1586,16 @@  static int __init ip_auto_config_setup(char *addrs)
 	if (ic_proto_name(addrs))
 		return 1;
 
+	/* This mean the kernel is not configured to have the method. */
+	if (strcmp(addrs, "dhcp") == 0 ||
+	    strcmp(addrs, "bootp") == 0 ||
+	    strcmp(addrs, "rarp") == 0 ||
+	    strcmp(addrs, "both") == 0) {
+		pr_warn("IP-Config: autoconf [%s] not compiled in\n", addrs);
+		ic_enable = 0;
+		return 1;
+	}
+
 	/* If no static IP is given, turn off autoconfig and bail.  */
 	if (*addrs == 0 ||
 	    strcmp(addrs, "off") == 0 ||