mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 06:23:02 +02:00
ipvlan: unregister upper devices outside pnodes_lock
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: 35add1093e ("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>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260828164918.451364-1-maciej.fijalkowski@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
4aa61c88b4
commit
a8455260b2
|
|
@ -848,7 +848,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:
|
||||
|
|
@ -899,6 +898,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user