diff options
author | Marcus Meissner <meissner@suse.de> | 2011-06-01 21:05:22 -0700 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2012-02-11 15:40:49 +0100 |
commit | 93050f523a0e91d818dc7290454a8ea746884ecd (patch) | |
tree | 6c3b91c0e5ca44f36545aee2eab7a4d2f353b2e3 | |
parent | af79350f1516512485de747775a1dde094a23e59 (diff) |
net/ipv4: Check for mistakenly passed in non-IPv4 address
[ Upstream commit d0733d2e29b652b2e7b1438ececa732e4eed98eb ]
Check against mistakenly passing in IPv6 addresses (which would result
in an INADDR_ANY bind) or similar incompatible sockaddrs.
Signed-off-by: Marcus Meissner <meissner@suse.de>
Cc: Reinhard Max <max@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r-- | net/ipv4/af_inet.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 8a3ac1fa71a..388c58d8c30 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -458,6 +458,9 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (addr_len < sizeof(struct sockaddr_in)) goto out; + if (addr->sin_family != AF_INET) + goto out; + chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); /* Not specified by any standard per-se, however it breaks too |