]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net/ipv4: Check for mistakenly passed in non-IPv4 address
authorMarcus Meissner <meissner@suse.de>
Thu, 2 Jun 2011 04:05:22 +0000 (21:05 -0700)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 Feb 2012 14:40:49 +0000 (15:40 +0100)
[ 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>
net/ipv4/af_inet.c

index 8a3ac1fa71a976e8c8f4c4f2dfd9fa87af2f9a99..388c58d8c30907ebfed3a0df16f9d3d1d7b477ac 100644 (file)
@@ -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