netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
@ 2019-06-27 12:03 Florian Westphal
  2019-06-27 12:03 ` [PATCH net-next 1/2] net: ipv4: fix infinite loop on secondary addr promotion Florian Westphal
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Florian Westphal @ 2019-06-27 12:03 UTC (permalink / raw)
  To: netdev; +Cc: ranro, tariqt

Tariq and Ran reported a regression caused by net-next commit
2638eb8b50cf ("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.

Florian Westphal (2):
      net: ipv4: fix infinite loop on secondary addr promotion
      selftests: rtnetlink: add small test case with 'promote_secondaries' enabled

 net/ipv4/devinet.c                       |    3 ++-
 tools/testing/selftests/net/rtnetlink.sh |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/2] net: ipv4: fix infinite loop on secondary addr promotion
  2019-06-27 12:03 [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop Florian Westphal
@ 2019-06-27 12:03 ` Florian Westphal
  2019-06-27 12:03 ` [PATCH net-next 2/2] selftests: rtnetlink: add small test case with 'promote_secondaries' enabled Florian Westphal
  2019-06-27 16:54 ` [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: Florian Westphal @ 2019-06-27 12:03 UTC (permalink / raw)
  To: netdev; +Cc: ranro, tariqt, Florian Westphal

secondary address promotion causes infinite loop -- it arranges
for ifa->ifa_next to point back to itself.

Problem is that 'prev_prom' and 'last_prim' might point at the same entry,
so 'last_sec' pointer must be obtained after prev_prom->next update.

Fixes: 2638eb8b50cf ("net: ipv4: provide __rcu annotation for ifa_list")
Reported-by: Ran Rozenstein <ranro@mellanox.com>
Reported-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/ipv4/devinet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7874303220c5..137d1892395d 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -428,8 +428,9 @@ static void __inet_del_ifa(struct in_device *in_dev,
 		if (prev_prom) {
 			struct in_ifaddr *last_sec;
 
-			last_sec = rtnl_dereference(last_prim->ifa_next);
 			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(last_prim->ifa_next, promote);
 		}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/2] selftests: rtnetlink: add small test case with 'promote_secondaries' enabled
  2019-06-27 12:03 [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop Florian Westphal
  2019-06-27 12:03 ` [PATCH net-next 1/2] net: ipv4: fix infinite loop on secondary addr promotion Florian Westphal
@ 2019-06-27 12:03 ` Florian Westphal
  2019-06-27 16:54 ` [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: Florian Westphal @ 2019-06-27 12:03 UTC (permalink / raw)
  To: netdev; +Cc: ranro, tariqt, Florian Westphal

This exercises the 'promote_secondaries' code path.

Without previous fix, this triggers infinite loop/soft lockup:
ifconfig process spinning at 100%, never to return.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tools/testing/selftests/net/rtnetlink.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index ed606a2e3865..505628884783 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -269,6 +269,25 @@ kci_test_addrlft()
 	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()
 {
 	ret=0
@@ -1161,6 +1180,7 @@ kci_test_rtnl()
 	kci_test_polrouting
 	kci_test_route_get
 	kci_test_addrlft
+	kci_test_promote_secondaries
 	kci_test_tc
 	kci_test_gre
 	kci_test_gretap
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
  2019-06-27 12:03 [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop Florian Westphal
  2019-06-27 12:03 ` [PATCH net-next 1/2] net: ipv4: fix infinite loop on secondary addr promotion Florian Westphal
  2019-06-27 12:03 ` [PATCH net-next 2/2] selftests: rtnetlink: add small test case with 'promote_secondaries' enabled Florian Westphal
@ 2019-06-27 16:54 ` David Miller
  2019-06-30  7:56   ` Tariq Toukan
  2 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2019-06-27 16:54 UTC (permalink / raw)
  To: fw; +Cc: netdev, ranro, tariqt

From: Florian Westphal <fw@strlen.de>
Date: Thu, 27 Jun 2019 14:03:31 +0200

> Tariq and Ran reported a regression caused by net-next commit
> 2638eb8b50cf ("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.

Series applied, thanks Florian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
  2019-06-27 16:54 ` [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop David Miller
@ 2019-06-30  7:56   ` Tariq Toukan
  2019-07-01  6:46     ` Ran Rozenstein
  0 siblings, 1 reply; 7+ messages in thread
From: Tariq Toukan @ 2019-06-30  7:56 UTC (permalink / raw)
  To: David Miller, fw; +Cc: netdev, Ran Rozenstein, Tariq Toukan



On 6/27/2019 7:54 PM, David Miller wrote:
> From: Florian Westphal <fw@strlen.de>
> Date: Thu, 27 Jun 2019 14:03:31 +0200
> 
>> Tariq and Ran reported a regression caused by net-next commit
>> 2638eb8b50cf ("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.
> 
> Series applied, thanks Florian.
> 

Thanks Florian!

Ran, please test and update.

Tariq

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
  2019-06-30  7:56   ` Tariq Toukan
@ 2019-07-01  6:46     ` Ran Rozenstein
  2019-07-01  7:21       ` Tariq Toukan
  0 siblings, 1 reply; 7+ messages in thread
From: Ran Rozenstein @ 2019-07-01  6:46 UTC (permalink / raw)
  To: Tariq Toukan, David Miller, fw; +Cc: netdev, Maor Gottlieb



> -----Original Message-----
> From: Tariq Toukan
> Sent: Sunday, June 30, 2019 10:57
> To: David Miller <davem@davemloft.net>; fw@strlen.de
> Cc: netdev@vger.kernel.org; Ran Rozenstein <ranro@mellanox.com>; Tariq
> Toukan <tariqt@mellanox.com>
> Subject: Re: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
> 
> 
> 
> On 6/27/2019 7:54 PM, David Miller wrote:
> > From: Florian Westphal <fw@strlen.de>
> > Date: Thu, 27 Jun 2019 14:03:31 +0200
> >
> >> Tariq and Ran reported a regression caused by net-next commit
> >> 2638eb8b50cf ("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.
> >
> > Series applied, thanks Florian.
> >
> 
> Thanks Florian!
> 
> Ran, please test and update.
> 
> Tariq

Thanks Florian.
Didn't reproduce tonight with the fixes.

Ran.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
  2019-07-01  6:46     ` Ran Rozenstein
@ 2019-07-01  7:21       ` Tariq Toukan
  0 siblings, 0 replies; 7+ messages in thread
From: Tariq Toukan @ 2019-07-01  7:21 UTC (permalink / raw)
  To: Ran Rozenstein, David Miller, fw; +Cc: netdev, Maor Gottlieb



On 7/1/2019 9:46 AM, Ran Rozenstein wrote:
> 
> 
>> -----Original Message-----
>> From: Tariq Toukan
>> Sent: Sunday, June 30, 2019 10:57
>> To: David Miller <davem@davemloft.net>; fw@strlen.de
>> Cc: netdev@vger.kernel.org; Ran Rozenstein <ranro@mellanox.com>; Tariq
>> Toukan <tariqt@mellanox.com>
>> Subject: Re: [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop
>>
>>
>>
>> On 6/27/2019 7:54 PM, David Miller wrote:
>>> From: Florian Westphal <fw@strlen.de>
>>> Date: Thu, 27 Jun 2019 14:03:31 +0200
>>>
>>>> Tariq and Ran reported a regression caused by net-next commit
>>>> 2638eb8b50cf ("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.
>>>
>>> Series applied, thanks Florian.
>>>
>>
>> Thanks Florian!
>>
>> Ran, please test and update.
>>
>> Tariq
> 
> Thanks Florian.
> Didn't reproduce tonight with the fixes.
> 
> Ran.
> 

Sounds good!

Thanks,
Tariq

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-01  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 12:03 [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop Florian Westphal
2019-06-27 12:03 ` [PATCH net-next 1/2] net: ipv4: fix infinite loop on secondary addr promotion Florian Westphal
2019-06-27 12:03 ` [PATCH net-next 2/2] selftests: rtnetlink: add small test case with 'promote_secondaries' enabled Florian Westphal
2019-06-27 16:54 ` [PATCH net-next 0/2] net: ipv4: fix circular-list infinite loop David Miller
2019-06-30  7:56   ` Tariq Toukan
2019-07-01  6:46     ` Ran Rozenstein
2019-07-01  7:21       ` Tariq Toukan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).