ipv6: Disallow binding to v4-mapped address on v6-only socket.
authorVlad Yasevich <vladislav.yasevich@hp.com>
Tue, 24 Mar 2009 16:24:48 +0000 (16:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Mar 2009 02:49:09 +0000 (19:49 -0700)
A socket marked v6-only, can not receive or send traffic to v4-mapped
addresses.  Thus allowing binding to v4-mapped address on such a
socket makes no sense.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/af_inet6.c

index fbf533cc9dcefdfb5b41f001224192518f855855..7f092fa912bd3eaf4fff2cbcc4cd92408e99a31c 100644 (file)
@@ -276,6 +276,13 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 
        /* Check if the address belongs to the host. */
        if (addr_type == IPV6_ADDR_MAPPED) {
+               /* Binding to v4-mapped address on a v6-only socket
+                * makes no sense
+                */
+               if (np->ipv6only) {
+                       err = -EINVAL;
+                       goto out;
+               }
                v4addr = addr->sin6_addr.s6_addr32[3];
                if (inet_addr_type(net, v4addr) != RTN_LOCAL) {
                        err = -EADDRNOTAVAIL;