netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* suspicious RCU usage in fib_table_flush_external
@ 2015-03-10 18:35 Sabrina Dubroca
  2015-03-10 18:45 ` Alexander Duyck
  2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
  0 siblings, 2 replies; 6+ messages in thread
From: Sabrina Dubroca @ 2015-03-10 18:35 UTC (permalink / raw)
  To: Scott Feldman; +Cc: Alexander Duyck, netdev

I ran into this while deleting a netns with some routes:

===============================
[ INFO: suspicious RCU usage. ]
4.0.0-rc2-00722-g8ac467e837a2-dirty #674 Not tainted
-------------------------------
net/ipv4/fib_trie.c:1606 suspicious rcu_dereference_protected() usage!
other info that might help us debug this:

rcu_scheduler_active = 1, debug_locks = 1
4 locks held by kworker/u4:1/50:
 #0:  ("%s""netns"){.+.+.+}, at: [<ffffffff81086525>] process_one_work+0x155/0x880
 #1:  (net_cleanup_work){+.+.+.}, at: [<ffffffff81086525>] process_one_work+0x155/0x880
 #2:  (net_mutex){+.+.+.}, at: [<ffffffff81647cfd>] cleanup_net+0x7d/0x230
 #3:  (&(&net->rules_mod_lock)->rlock){+.+...}, at: [<ffffffff81674ce4>] fib_rules_unregister+0x34/0x100
 stack backtrace:
CPU: 1 PID: 50 Comm: kworker/u4:1 Not tainted 4.0.0-rc2-00722-g8ac467e837a2-dirty #674
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140617_173321-var-lib-archbuild-testing-x86_64-tobias 04/01/2014
Workqueue: netns cleanup_net
 0000000000000001 ffff88001dffbba8 ffffffff81835bd0 0000000000000011
 ffff88001dd95690 ffff88001dffbbd8 ffffffff810b5505 0000000000000001
 0000000000000001 ffff88001da86270 ffff88001d528008 ffff88001dffbc08
Call Trace:
 [<ffffffff81835bd0>] dump_stack+0x4c/0x6e
 [<ffffffff810b5505>] lockdep_rcu_suspicious+0xd5/0x110
 [<ffffffff81710421>] fib_table_flush_external+0xe1/0x130
 [<ffffffff81708808>] fib_flush_external+0x38/0x60
 [<ffffffff81719dee>] fib4_rule_delete+0x2e/0x30
 [<ffffffff81674d4b>] fib_rules_unregister+0x9b/0x100
 [<ffffffff8171a2a5>] fib4_rules_exit+0x15/0x20
 [<ffffffff817078ab>] ip_fib_net_exit+0x1b/0x120
 [<ffffffff817079e5>] fib_net_exit+0x35/0x40



since fib_table_flush_external wants RTNL, should we just move
rtnl_lock() before fib4_rules_exit in ip_fib_net_exit?


diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index e067770235bf..ed94bc80eb78 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1126,11 +1126,12 @@ static void ip_fib_net_exit(struct net *net)
 {
 	unsigned int i;
 
+	rtnl_lock();
+
 #ifdef CONFIG_IP_MULTIPLE_TABLES
 	fib4_rules_exit(net);
 #endif
 
-	rtnl_lock();
 	for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
 		struct hlist_head *head = &net->ipv4.fib_table_hash[i];
 		struct hlist_node *tmp;

-- 
Sabrina

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

* Re: suspicious RCU usage in fib_table_flush_external
  2015-03-10 18:35 suspicious RCU usage in fib_table_flush_external Sabrina Dubroca
@ 2015-03-10 18:45 ` Alexander Duyck
  2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Duyck @ 2015-03-10 18:45 UTC (permalink / raw)
  To: Sabrina Dubroca, Scott Feldman; +Cc: netdev

On 03/10/2015 11:35 AM, Sabrina Dubroca wrote:
> I ran into this while deleting a netns with some routes:
>
> ===============================
> [ INFO: suspicious RCU usage. ]
> 4.0.0-rc2-00722-g8ac467e837a2-dirty #674 Not tainted
> -------------------------------
> net/ipv4/fib_trie.c:1606 suspicious rcu_dereference_protected() usage!
> other info that might help us debug this:
>
> rcu_scheduler_active = 1, debug_locks = 1
> 4 locks held by kworker/u4:1/50:
>   #0:  ("%s""netns"){.+.+.+}, at: [<ffffffff81086525>] process_one_work+0x155/0x880
>   #1:  (net_cleanup_work){+.+.+.}, at: [<ffffffff81086525>] process_one_work+0x155/0x880
>   #2:  (net_mutex){+.+.+.}, at: [<ffffffff81647cfd>] cleanup_net+0x7d/0x230
>   #3:  (&(&net->rules_mod_lock)->rlock){+.+...}, at: [<ffffffff81674ce4>] fib_rules_unregister+0x34/0x100
>   stack backtrace:
> CPU: 1 PID: 50 Comm: kworker/u4:1 Not tainted 4.0.0-rc2-00722-g8ac467e837a2-dirty #674
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140617_173321-var-lib-archbuild-testing-x86_64-tobias 04/01/2014
> Workqueue: netns cleanup_net
>   0000000000000001 ffff88001dffbba8 ffffffff81835bd0 0000000000000011
>   ffff88001dd95690 ffff88001dffbbd8 ffffffff810b5505 0000000000000001
>   0000000000000001 ffff88001da86270 ffff88001d528008 ffff88001dffbc08
> Call Trace:
>   [<ffffffff81835bd0>] dump_stack+0x4c/0x6e
>   [<ffffffff810b5505>] lockdep_rcu_suspicious+0xd5/0x110
>   [<ffffffff81710421>] fib_table_flush_external+0xe1/0x130
>   [<ffffffff81708808>] fib_flush_external+0x38/0x60
>   [<ffffffff81719dee>] fib4_rule_delete+0x2e/0x30
>   [<ffffffff81674d4b>] fib_rules_unregister+0x9b/0x100
>   [<ffffffff8171a2a5>] fib4_rules_exit+0x15/0x20
>   [<ffffffff817078ab>] ip_fib_net_exit+0x1b/0x120
>   [<ffffffff817079e5>] fib_net_exit+0x35/0x40
>
>
>
> since fib_table_flush_external wants RTNL, should we just move
> rtnl_lock() before fib4_rules_exit in ip_fib_net_exit?
>
>
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index e067770235bf..ed94bc80eb78 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -1126,11 +1126,12 @@ static void ip_fib_net_exit(struct net *net)
>   {
>   	unsigned int i;
>   
> +	rtnl_lock();
> +
>   #ifdef CONFIG_IP_MULTIPLE_TABLES
>   	fib4_rules_exit(net);
>   #endif
>   
> -	rtnl_lock();
>   	for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
>   		struct hlist_head *head = &net->ipv4.fib_table_hash[i];
>   		struct hlist_node *tmp;
>

This fix looks like it is probably correct.  I'd recommend including a 
note that it fixes 104616e74 ("switchdev: don't support custom ip rules, 
for now"), and make sure to include a signed-off-by.

- Alex

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

* [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL
  2015-03-10 18:35 suspicious RCU usage in fib_table_flush_external Sabrina Dubroca
  2015-03-10 18:45 ` Alexander Duyck
@ 2015-03-10 20:03 ` Sabrina Dubroca
  2015-03-10 20:38   ` Alexander Duyck
                     ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Sabrina Dubroca @ 2015-03-10 20:03 UTC (permalink / raw)
  To: davem; +Cc: netdev, alexander.h.duyck, sfeldma, Sabrina Dubroca

Move rtnl_lock() before the call to fib4_rules_exit so that
fib_table_flush_external is called under RTNL.

Fixes: 104616e74e0b ("switchdev: don't support custom ip rules, for now")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/ipv4/fib_frontend.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index e067770235bf..ed94bc80eb78 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1126,11 +1126,12 @@ static void ip_fib_net_exit(struct net *net)
 {
 	unsigned int i;
 
+	rtnl_lock();
+
 #ifdef CONFIG_IP_MULTIPLE_TABLES
 	fib4_rules_exit(net);
 #endif
 
-	rtnl_lock();
 	for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
 		struct hlist_head *head = &net->ipv4.fib_table_hash[i];
 		struct hlist_node *tmp;
-- 
2.3.2

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

* Re: [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL
  2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
@ 2015-03-10 20:38   ` Alexander Duyck
  2015-03-11 13:00   ` Jiri Pirko
  2015-03-11 20:46   ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Alexander Duyck @ 2015-03-10 20:38 UTC (permalink / raw)
  To: Sabrina Dubroca, davem; +Cc: netdev, sfeldma

On 03/10/2015 01:03 PM, Sabrina Dubroca wrote:
> Move rtnl_lock() before the call to fib4_rules_exit so that
> fib_table_flush_external is called under RTNL.
>
> Fixes: 104616e74e0b ("switchdev: don't support custom ip rules, for now")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> ---
>   net/ipv4/fib_frontend.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index e067770235bf..ed94bc80eb78 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -1126,11 +1126,12 @@ static void ip_fib_net_exit(struct net *net)
>   {
>   	unsigned int i;
>   
> +	rtnl_lock();
> +
>   #ifdef CONFIG_IP_MULTIPLE_TABLES
>   	fib4_rules_exit(net);
>   #endif
>   
> -	rtnl_lock();
>   	for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
>   		struct hlist_head *head = &net->ipv4.fib_table_hash[i];
>   		struct hlist_node *tmp;

Acked-by: Alexander Duyck <alexander.h.duyck@redhat.com>

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

* Re: [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL
  2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
  2015-03-10 20:38   ` Alexander Duyck
@ 2015-03-11 13:00   ` Jiri Pirko
  2015-03-11 20:46   ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2015-03-11 13:00 UTC (permalink / raw)
  To: Sabrina Dubroca; +Cc: davem, netdev, alexander.h.duyck, sfeldma

Tue, Mar 10, 2015 at 09:03:54PM CET, sd@queasysnail.net wrote:
>Move rtnl_lock() before the call to fib4_rules_exit so that
>fib_table_flush_external is called under RTNL.
>
>Fixes: 104616e74e0b ("switchdev: don't support custom ip rules, for now")
>Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>


Reviewed-by: Jiri Pirko <jiri@resnulli.us>

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

* Re: [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL
  2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
  2015-03-10 20:38   ` Alexander Duyck
  2015-03-11 13:00   ` Jiri Pirko
@ 2015-03-11 20:46   ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-03-11 20:46 UTC (permalink / raw)
  To: sd; +Cc: netdev, alexander.h.duyck, sfeldma

From: Sabrina Dubroca <sd@queasysnail.net>
Date: Tue, 10 Mar 2015 21:03:54 +0100

> Move rtnl_lock() before the call to fib4_rules_exit so that
> fib_table_flush_external is called under RTNL.
> 
> Fixes: 104616e74e0b ("switchdev: don't support custom ip rules, for now")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Applied, thanks a lot.

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

end of thread, other threads:[~2015-03-11 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-10 18:35 suspicious RCU usage in fib_table_flush_external Sabrina Dubroca
2015-03-10 18:45 ` Alexander Duyck
2015-03-10 20:03 ` [PATCH net-next] fib_trie: call fib_table_flush_external under RTNL Sabrina Dubroca
2015-03-10 20:38   ` Alexander Duyck
2015-03-11 13:00   ` Jiri Pirko
2015-03-11 20:46   ` David Miller

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).