diff options
author | Rabin Vincent <rabinv@axis.com> | 2017-04-10 02:36:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-12 13:23:39 -0400 |
commit | a2d6cbb0670d54806f18192cb0db266b4a6d285a (patch) | |
tree | b1e8048ca0a255ece74d79c3e9095c2b99e265ce | |
parent | df7dd8fc965c665e83b71a649378cdf200ff36df (diff) |
ipv6: Fix idev->addr_list corruption
addrconf_ifdown() removes elements from the idev->addr_list without
holding the idev->lock.
If this happens while the loop in __ipv6_dev_get_saddr() is handling the
same element, that function ends up in an infinite loop:
NMI watchdog: BUG: soft lockup - CPU#1 stuck for 23s! [test:1719]
Call Trace:
ipv6_get_saddr_eval+0x13c/0x3a0
__ipv6_dev_get_saddr+0xe4/0x1f0
ipv6_dev_get_saddr+0x1b4/0x204
ip6_dst_lookup_tail+0xcc/0x27c
ip6_dst_lookup_flow+0x38/0x80
udpv6_sendmsg+0x708/0xba8
sock_sendmsg+0x18/0x30
SyS_sendto+0xb8/0xf8
syscall_common+0x34/0x58
Fixes: 6a923934c33 (Revert "ipv6: Revert optional address flusing on ifdown.")
Signed-off-by: Rabin Vincent <rabinv@axis.com>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/addrconf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 363172527e43..80ce478c4851 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3626,14 +3626,19 @@ restart: | |||
3626 | INIT_LIST_HEAD(&del_list); | 3626 | INIT_LIST_HEAD(&del_list); |
3627 | list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { | 3627 | list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { |
3628 | struct rt6_info *rt = NULL; | 3628 | struct rt6_info *rt = NULL; |
3629 | bool keep; | ||
3629 | 3630 | ||
3630 | addrconf_del_dad_work(ifa); | 3631 | addrconf_del_dad_work(ifa); |
3631 | 3632 | ||
3633 | keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) && | ||
3634 | !addr_is_local(&ifa->addr); | ||
3635 | if (!keep) | ||
3636 | list_move(&ifa->if_list, &del_list); | ||
3637 | |||
3632 | write_unlock_bh(&idev->lock); | 3638 | write_unlock_bh(&idev->lock); |
3633 | spin_lock_bh(&ifa->lock); | 3639 | spin_lock_bh(&ifa->lock); |
3634 | 3640 | ||
3635 | if (keep_addr && (ifa->flags & IFA_F_PERMANENT) && | 3641 | if (keep) { |
3636 | !addr_is_local(&ifa->addr)) { | ||
3637 | /* set state to skip the notifier below */ | 3642 | /* set state to skip the notifier below */ |
3638 | state = INET6_IFADDR_STATE_DEAD; | 3643 | state = INET6_IFADDR_STATE_DEAD; |
3639 | ifa->state = 0; | 3644 | ifa->state = 0; |
@@ -3645,8 +3650,6 @@ restart: | |||
3645 | } else { | 3650 | } else { |
3646 | state = ifa->state; | 3651 | state = ifa->state; |
3647 | ifa->state = INET6_IFADDR_STATE_DEAD; | 3652 | ifa->state = INET6_IFADDR_STATE_DEAD; |
3648 | |||
3649 | list_move(&ifa->if_list, &del_list); | ||
3650 | } | 3653 | } |
3651 | 3654 | ||
3652 | spin_unlock_bh(&ifa->lock); | 3655 | spin_unlock_bh(&ifa->lock); |