BPF List
 help / color / mirror / Atom feed
* [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock
@ 2026-08-28 16:49 Maciej Fijalkowski
  2026-08-28 16:51 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maciej Fijalkowski @ 2026-08-28 16:49 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	magnus.karlsson, sdf, bpf, syzbot+aa48b5fe7bfda62d1682,
	Maciej Fijalkowski

syzbot reported the following circular locking dependency:

  xs->mutex -> netdev lock -> pnodes_lock -> net->xdp.lock -> xs->mutex

The pnodes_lock -> net->xdp.lock edge is recorded when
ipvlan_device_event(NETDEV_UNREGISTER) calls unregister_netdevice_many()
while holding pnodes_lock.  A nested NETDEV_UNREGISTER notification for
an IPvlan device enters xsk_notifier(), which acquires net->xdp.lock.

Keep pnodes_lock only while marking the upper devices as dying, removing
them from port->ipvlans, and queueing them for unregistration.  Once the
devices have been detached from the protected list, release pnodes_lock
before unregister_netdevice_many() invokes notifier callbacks.

The port remains alive across unregistration because
ipvlan_device_event() holds the reference acquired by ipvlan_port_get().
The dying flag prevents a concurrent ->dellink() callback from deleting a
queued device again.

Fixes: 35add1093e2f ("ipvlan: Protect ipvl_port.ipvlans with mutex.")
Reported-by: syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=aa48b5fe7bfda62d1682
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
v2: avoid list_empty() check as unregister_netdevice_many() already does
    it for us (Kuniyuki)
---
 drivers/net/ipvlan/ipvlan_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index ee46a55f73d1..2d4340627ca6 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -846,7 +846,6 @@ static int ipvlan_device_event(struct notifier_block *unused,
 				__ipvlan_link_delete(net, ipvlan->dev, &lst_kill);
 		}
 
-		unregister_netdevice_many(&lst_kill);
 		break;
 	}
 	case NETDEV_FEAT_CHANGE:
@@ -895,6 +894,9 @@ static int ipvlan_device_event(struct notifier_block *unused,
 
 	mutex_unlock(&port->pnodes_lock);
 
+	/* Avoid invoking nested netdevice notifiers under pnodes_lock. */
+	unregister_netdevice_many(&lst_kill);
+
 	ipvlan_port_put(port);
 
 	return ret;
-- 
2.43.0


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

* Re: [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock
  2026-08-28 16:49 [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock Maciej Fijalkowski
@ 2026-08-28 16:51 ` Eric Dumazet
  2026-08-28 17:03 ` Kuniyuki Iwashima
  2026-08-30 21:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-08-28 16:51 UTC (permalink / raw)
  To: Maciej Fijalkowski
  Cc: netdev, andrew+netdev, davem, kuba, pabeni, kuniyu,
	magnus.karlsson, sdf, bpf, syzbot+aa48b5fe7bfda62d1682

On Fri, Aug 28, 2026 at 6:49 PM Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> syzbot reported the following circular locking dependency:
>
>   xs->mutex -> netdev lock -> pnodes_lock -> net->xdp.lock -> xs->mutex
>
> The pnodes_lock -> net->xdp.lock edge is recorded when
> ipvlan_device_event(NETDEV_UNREGISTER) calls unregister_netdevice_many()
> while holding pnodes_lock.  A nested NETDEV_UNREGISTER notification for
> an IPvlan device enters xsk_notifier(), which acquires net->xdp.lock.
>
> Keep pnodes_lock only while marking the upper devices as dying, removing
> them from port->ipvlans, and queueing them for unregistration.  Once the
> devices have been detached from the protected list, release pnodes_lock
> before unregister_netdevice_many() invokes notifier callbacks.
>
> The port remains alive across unregistration because
> ipvlan_device_event() holds the reference acquired by ipvlan_port_get().
> The dying flag prevents a concurrent ->dellink() callback from deleting a
> queued device again.
>
> Fixes: 35add1093e2f ("ipvlan: Protect ipvl_port.ipvlans with mutex.")
> Reported-by: syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=aa48b5fe7bfda62d1682
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock
  2026-08-28 16:49 [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock Maciej Fijalkowski
  2026-08-28 16:51 ` Eric Dumazet
@ 2026-08-28 17:03 ` Kuniyuki Iwashima
  2026-08-30 21:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2026-08-28 17:03 UTC (permalink / raw)
  To: Maciej Fijalkowski
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni,
	magnus.karlsson, sdf, bpf, syzbot+aa48b5fe7bfda62d1682

On Fri, Aug 28, 2026 at 9:49 AM Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> syzbot reported the following circular locking dependency:
>
>   xs->mutex -> netdev lock -> pnodes_lock -> net->xdp.lock -> xs->mutex
>
> The pnodes_lock -> net->xdp.lock edge is recorded when
> ipvlan_device_event(NETDEV_UNREGISTER) calls unregister_netdevice_many()
> while holding pnodes_lock.  A nested NETDEV_UNREGISTER notification for
> an IPvlan device enters xsk_notifier(), which acquires net->xdp.lock.
>
> Keep pnodes_lock only while marking the upper devices as dying, removing
> them from port->ipvlans, and queueing them for unregistration.  Once the
> devices have been detached from the protected list, release pnodes_lock
> before unregister_netdevice_many() invokes notifier callbacks.
>
> The port remains alive across unregistration because
> ipvlan_device_event() holds the reference acquired by ipvlan_port_get().
> The dying flag prevents a concurrent ->dellink() callback from deleting a
> queued device again.
>
> Fixes: 35add1093e2f ("ipvlan: Protect ipvl_port.ipvlans with mutex.")
> Reported-by: syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=aa48b5fe7bfda62d1682
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

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

Thanks!

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

* Re: [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock
  2026-08-28 16:49 [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock Maciej Fijalkowski
  2026-08-28 16:51 ` Eric Dumazet
  2026-08-28 17:03 ` Kuniyuki Iwashima
@ 2026-08-30 21:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-30 21:50 UTC (permalink / raw)
  To: Maciej Fijalkowski
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	magnus.karlsson, sdf, bpf, syzbot+aa48b5fe7bfda62d1682

Hello:

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

On Fri, 28 Aug 2026 18:49:18 +0200 you wrote:
> syzbot reported the following circular locking dependency:
> 
>   xs->mutex -> netdev lock -> pnodes_lock -> net->xdp.lock -> xs->mutex
> 
> The pnodes_lock -> net->xdp.lock edge is recorded when
> ipvlan_device_event(NETDEV_UNREGISTER) calls unregister_netdevice_many()
> while holding pnodes_lock.  A nested NETDEV_UNREGISTER notification for
> an IPvlan device enters xsk_notifier(), which acquires net->xdp.lock.
> 
> [...]

Here is the summary with links:
  - [v2,net] ipvlan: unregister upper devices outside pnodes_lock
    https://git.kernel.org/netdev/net/c/a8455260b2e9

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] 4+ messages in thread

end of thread, other threads:[~2026-08-30 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 16:49 [PATCH v2 net] ipvlan: unregister upper devices outside pnodes_lock Maciej Fijalkowski
2026-08-28 16:51 ` Eric Dumazet
2026-08-28 17:03 ` Kuniyuki Iwashima
2026-08-30 21:50 ` 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