Skip to content

Commit a2d6cbb

Browse files
vwaxdavem330
authored andcommitted
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: 6a92393 (Revert "ipv6: Revert optional address flusing on ifdown.") Signed-off-by: Rabin Vincent <[email protected]> Acked-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df7dd8f commit a2d6cbb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/ipv6/addrconf.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,14 +3626,19 @@ static int addrconf_ifdown(struct net_device *dev, int how)
36263626
INIT_LIST_HEAD(&del_list);
36273627
list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) {
36283628
struct rt6_info *rt = NULL;
3629+
bool keep;
36293630

36303631
addrconf_del_dad_work(ifa);
36313632

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+
36323638
write_unlock_bh(&idev->lock);
36333639
spin_lock_bh(&ifa->lock);
36343640

3635-
if (keep_addr && (ifa->flags & IFA_F_PERMANENT) &&
3636-
!addr_is_local(&ifa->addr)) {
3641+
if (keep) {
36373642
/* set state to skip the notifier below */
36383643
state = INET6_IFADDR_STATE_DEAD;
36393644
ifa->state = 0;
@@ -3645,8 +3650,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
36453650
} else {
36463651
state = ifa->state;
36473652
ifa->state = INET6_IFADDR_STATE_DEAD;
3648-
3649-
list_move(&ifa->if_list, &del_list);
36503653
}
36513654

36523655
spin_unlock_bh(&ifa->lock);

0 commit comments

Comments
 (0)