netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify()
@ 2025-01-29 14:27 Eric Dumazet
  2025-01-30  0:49 ` Kuniyuki Iwashima
  2025-01-30 17:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-01-29 14:27 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, Simon Horman, eric.dumazet, Eric Dumazet,
	syzbot+5b9196ecf74447172a9a

This patch reverts following changes:

83419b61d187 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)
ae646f1a0bb9 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)
cfa579f66656 net: no longer hold RTNL while calling flush_all_backlogs()

This caused issues in layers holding a private mutex:

cleanup_net()
  rtnl_lock();
	mutex_lock(subsystem_mutex);

	unregister_netdevice();

	   rtnl_unlock();		// LOCKDEP violation
	   rtnl_lock();

I will revisit this in next cycle, opt-in for the new behavior
from safe contexts only.

Fixes: cfa579f66656 ("net: no longer hold RTNL while calling flush_all_backlogs()")
Fixes: ae646f1a0bb9 ("net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)")
Fixes: 83419b61d187 ("net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)")
Reported-by: syzbot+5b9196ecf74447172a9a@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6789d55f.050a0220.20d369.004e.GAE@google.com/
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 07b2bb1ce64f..63e5dc75d58b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10260,37 +10260,14 @@ static bool from_cleanup_net(void)
 #endif
 }
 
-static void rtnl_drop_if_cleanup_net(void)
-{
-	if (from_cleanup_net())
-		__rtnl_unlock();
-}
-
-static void rtnl_acquire_if_cleanup_net(void)
-{
-	if (from_cleanup_net())
-		rtnl_lock();
-}
-
 /* Delayed registration/unregisteration */
 LIST_HEAD(net_todo_list);
-static LIST_HEAD(net_todo_list_for_cleanup_net);
-
-/* TODO: net_todo_list/net_todo_list_for_cleanup_net should probably
- * be provided by callers, instead of being static, rtnl protected.
- */
-static struct list_head *todo_list(void)
-{
-	return from_cleanup_net() ? &net_todo_list_for_cleanup_net :
-				    &net_todo_list;
-}
-
 DECLARE_WAIT_QUEUE_HEAD(netdev_unregistering_wq);
 atomic_t dev_unreg_count = ATOMIC_INIT(0);
 
 static void net_set_todo(struct net_device *dev)
 {
-	list_add_tail(&dev->todo_list, todo_list());
+	list_add_tail(&dev->todo_list, &net_todo_list);
 }
 
 static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
@@ -11140,7 +11117,7 @@ void netdev_run_todo(void)
 #endif
 
 	/* Snapshot list, allow later requests */
-	list_replace_init(todo_list(), &list);
+	list_replace_init(&net_todo_list, &list);
 
 	__rtnl_unlock();
 
@@ -11785,11 +11762,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
 		WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING);
 		netdev_unlock(dev);
 	}
-
-	rtnl_drop_if_cleanup_net();
 	flush_all_backlogs();
+
 	synchronize_net();
-	rtnl_acquire_if_cleanup_net();
 
 	list_for_each_entry(dev, head, unreg_list) {
 		struct sk_buff *skb = NULL;
@@ -11849,9 +11824,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
 #endif
 	}
 
-	rtnl_drop_if_cleanup_net();
 	synchronize_net();
-	rtnl_acquire_if_cleanup_net();
 
 	list_for_each_entry(dev, head, unreg_list) {
 		netdev_put(dev, &dev->dev_registered_tracker);
-- 
2.48.1.262.g85cc9f2d1e-goog


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

* Re: [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify()
  2025-01-29 14:27 [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify() Eric Dumazet
@ 2025-01-30  0:49 ` Kuniyuki Iwashima
  2025-01-30 17:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2025-01-30  0:49 UTC (permalink / raw)
  To: edumazet
  Cc: davem, eric.dumazet, horms, kuba, netdev, pabeni,
	syzbot+5b9196ecf74447172a9a, Kuniyuki Iwashima

From: Eric Dumazet <edumazet@google.com>
Date: Wed, 29 Jan 2025 14:27:26 +0000
> This patch reverts following changes:
> 
> 83419b61d187 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)
> ae646f1a0bb9 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)
> cfa579f66656 net: no longer hold RTNL while calling flush_all_backlogs()
> 
> This caused issues in layers holding a private mutex:
> 
> cleanup_net()
>   rtnl_lock();
> 	mutex_lock(subsystem_mutex);
> 
> 	unregister_netdevice();
> 
> 	   rtnl_unlock();		// LOCKDEP violation
> 	   rtnl_lock();
> 
> I will revisit this in next cycle, opt-in for the new behavior
> from safe contexts only.
> 
> Fixes: cfa579f66656 ("net: no longer hold RTNL while calling flush_all_backlogs()")
> Fixes: ae646f1a0bb9 ("net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)")
> Fixes: 83419b61d187 ("net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)")
> Reported-by: syzbot+5b9196ecf74447172a9a@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/6789d55f.050a0220.20d369.004e.GAE@google.com/
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

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

* Re: [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify()
  2025-01-29 14:27 [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify() Eric Dumazet
  2025-01-30  0:49 ` Kuniyuki Iwashima
@ 2025-01-30 17:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-30 17:10 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, netdev, horms, eric.dumazet,
	syzbot+5b9196ecf74447172a9a

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 29 Jan 2025 14:27:26 +0000 you wrote:
> This patch reverts following changes:
> 
> 83419b61d187 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 2)
> ae646f1a0bb9 net: reduce RTNL hold duration in unregister_netdevice_many_notify() (part 1)
> cfa579f66656 net: no longer hold RTNL while calling flush_all_backlogs()
> 
> This caused issues in layers holding a private mutex:
> 
> [...]

Here is the summary with links:
  - [net] net: revert RTNL changes in unregister_netdevice_many_notify()
    https://git.kernel.org/netdev/net/c/e759e1e4a4bd

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-01-30 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 14:27 [PATCH net] net: revert RTNL changes in unregister_netdevice_many_notify() Eric Dumazet
2025-01-30  0:49 ` Kuniyuki Iwashima
2025-01-30 17:10 ` patchwork-bot+netdevbpf

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