Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netvsc: fix rtnl deadlock on unregister of vf

With new transparent VF support, it is possible to get a deadlock
when some of the deferred work is running and the unregister_vf
is trying to cancel the work element. The solution is to use
trylock and reschedule (similar to bonding and team device).

Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Fixes: 0c195567a8f6 ("netvsc: transparent VF management")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

stephen hemminger and committed by
David S. Miller
fb84af8a 5f6b4e14

+10 -2
+10 -2
drivers/net/hyperv/netvsc_drv.c
··· 1601 1601 struct net_device *ndev = hv_get_drvdata(ndev_ctx->device_ctx); 1602 1602 struct net_device *vf_netdev; 1603 1603 1604 - rtnl_lock(); 1604 + if (!rtnl_trylock()) { 1605 + schedule_work(w); 1606 + return; 1607 + } 1608 + 1605 1609 vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); 1606 1610 if (vf_netdev) 1607 1611 __netvsc_vf_setup(ndev, vf_netdev); ··· 1659 1655 struct net_device *vf_netdev; 1660 1656 bool vf_is_up; 1661 1657 1662 - rtnl_lock(); 1658 + if (!rtnl_trylock()) { 1659 + schedule_work(w); 1660 + return; 1661 + } 1662 + 1663 1663 vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); 1664 1664 if (!vf_netdev) 1665 1665 goto unlock;