aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ipvlan/ipvlan_main.c
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2015-03-28 14:13:22 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-31 13:28:33 -0400
commit27705f7085ce2e124fac4c280ce824962cc90bb6 (patch)
tree75496324aa43dd29aff4a12f44ee2b19e5b27f0d /drivers/net/ipvlan/ipvlan_main.c
parent63c607321492c5efc7a31bc4ea734b877f8e7f87 (diff)
ipvlan: fix addr hash list corruption
When ipvlan interface with IP addresses attached is brought down and then deleted, the assigned addresses are deleted twice from the address hash list, first on the interface down and second on the link deletion. Similarly, when an address is added while the interface is down, it is added second time once the interface is brought up. When the interface is down, the addresses should be kept off the hash list for performance reasons. Ensure this is true, which also fixes the double add problem. To fix the double free, check whether the address is hashed before removing it. Reported-by: Dan Williams <dcbw@redhat.com> Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Mahesh Bandewar <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipvlan/ipvlan_main.c')
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4f4099d5603d..1eb3f33e11cc 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -622,7 +622,11 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
622 addr->atype = IPVL_IPV6; 622 addr->atype = IPVL_IPV6;
623 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 623 list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
624 ipvlan->ipv6cnt++; 624 ipvlan->ipv6cnt++;
625 ipvlan_ht_addr_add(ipvlan, addr); 625 /* If the interface is not up, the address will be added to the hash
626 * list by ipvlan_open.
627 */
628 if (netif_running(ipvlan->dev))
629 ipvlan_ht_addr_add(ipvlan, addr);
626 630
627 return 0; 631 return 0;
628} 632}
@@ -690,7 +694,11 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
690 addr->atype = IPVL_IPV4; 694 addr->atype = IPVL_IPV4;
691 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 695 list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
692 ipvlan->ipv4cnt++; 696 ipvlan->ipv4cnt++;
693 ipvlan_ht_addr_add(ipvlan, addr); 697 /* If the interface is not up, the address will be added to the hash
698 * list by ipvlan_open.
699 */
700 if (netif_running(ipvlan->dev))
701 ipvlan_ht_addr_add(ipvlan, addr);
694 ipvlan_set_broadcast_mac_filter(ipvlan, true); 702 ipvlan_set_broadcast_mac_filter(ipvlan, true);
695 703
696 return 0; 704 return 0;