Commit 582737f9 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-ipv4-fix-circular-list-infinite-loop'

Florian Westphal says:

====================
net: ipv4: fix circular-list infinite loop

Tariq and Ran reported a regression caused by net-next commit
2638eb8b ("net: ipv4: provide __rcu annotation for ifa_list").

This happens when net.ipv4.conf.$dev.promote_secondaries sysctl is
enabled -- we can arrange for ifa->next to point at ifa, so next
process that tries to walk the list loops forever.

Fix this and extend rtnetlink.sh with a small test case for this.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5b9469a2 bb2bd090
...@@ -428,8 +428,9 @@ static void __inet_del_ifa(struct in_device *in_dev, ...@@ -428,8 +428,9 @@ static void __inet_del_ifa(struct in_device *in_dev,
if (prev_prom) { if (prev_prom) {
struct in_ifaddr *last_sec; struct in_ifaddr *last_sec;
last_sec = rtnl_dereference(last_prim->ifa_next);
rcu_assign_pointer(prev_prom->ifa_next, next_sec); rcu_assign_pointer(prev_prom->ifa_next, next_sec);
last_sec = rtnl_dereference(last_prim->ifa_next);
rcu_assign_pointer(promote->ifa_next, last_sec); rcu_assign_pointer(promote->ifa_next, last_sec);
rcu_assign_pointer(last_prim->ifa_next, promote); rcu_assign_pointer(last_prim->ifa_next, promote);
} }
......
...@@ -269,6 +269,25 @@ kci_test_addrlft() ...@@ -269,6 +269,25 @@ kci_test_addrlft()
echo "PASS: preferred_lft addresses have expired" echo "PASS: preferred_lft addresses have expired"
} }
kci_test_promote_secondaries()
{
promote=$(sysctl -n net.ipv4.conf.$devdummy.promote_secondaries)
sysctl -q net.ipv4.conf.$devdummy.promote_secondaries=1
for i in $(seq 2 254);do
IP="10.23.11.$i"
ip -f inet addr add $IP/16 brd + dev "$devdummy"
ifconfig "$devdummy" $IP netmask 255.255.0.0
done
ip addr flush dev "$devdummy"
[ $promote -eq 0 ] && sysctl -q net.ipv4.conf.$devdummy.promote_secondaries=0
echo "PASS: promote_secondaries complete"
}
kci_test_addrlabel() kci_test_addrlabel()
{ {
ret=0 ret=0
...@@ -1161,6 +1180,7 @@ kci_test_rtnl() ...@@ -1161,6 +1180,7 @@ kci_test_rtnl()
kci_test_polrouting kci_test_polrouting
kci_test_route_get kci_test_route_get
kci_test_addrlft kci_test_addrlft
kci_test_promote_secondaries
kci_test_tc kci_test_tc
kci_test_gre kci_test_gre
kci_test_gretap kci_test_gretap
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment