]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCTP]: IPv4 vs IPv6 addresses mess in sctp_inet[6]addr_event.
authorPavel Emelyanov <xemul@openvz.org>
Sun, 13 Apr 2008 01:40:38 +0000 (18:40 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 13 Apr 2008 01:40:38 +0000 (18:40 -0700)
All IP addresses that are present in a system are duplicated on
struct sctp_sockaddr_entry. They are linked in the global list
called sctp_local_addr_list. And this struct unions IPv4 and IPv6
addresses.

So, there can be rare case, when a sockaddr_in.sin_addr coincides
with the corresponding part of the sockaddr_in6 and the notifier
for IPv4 will carry away an IPv6 entry.

The fix is to check the family before comparing the addresses.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/ipv6.c
net/sctp/protocol.c

index b1e05d719f9b4ab59047e26bfaed80dc02e91747..85f1495e0edc82e85ace76533a399e343573b7c6 100644 (file)
@@ -110,8 +110,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
                spin_lock_bh(&sctp_local_addr_lock);
                list_for_each_entry_safe(addr, temp,
                                        &sctp_local_addr_list, list) {
-                       if (ipv6_addr_equal(&addr->a.v6.sin6_addr,
-                                            &ifa->addr)) {
+                       if (addr->a.sa.sa_family == AF_INET6 &&
+                                       ipv6_addr_equal(&addr->a.v6.sin6_addr,
+                                               &ifa->addr)) {
                                found = 1;
                                addr->valid = 0;
                                list_del_rcu(&addr->list);
index f90091a1b9ce9b257d201aef211bd79d4d33a262..c2dd65d9f38da7de0a8bd0170e766a3bb9936733 100644 (file)
@@ -647,7 +647,9 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
                spin_lock_bh(&sctp_local_addr_lock);
                list_for_each_entry_safe(addr, temp,
                                        &sctp_local_addr_list, list) {
-                       if (addr->a.v4.sin_addr.s_addr == ifa->ifa_local) {
+                       if (addr->a.sa.sa_family == AF_INET &&
+                                       addr->a.v4.sin_addr.s_addr ==
+                                       ifa->ifa_local) {
                                found = 1;
                                addr->valid = 0;
                                list_del_rcu(&addr->list);