Merge branch 'devlink-deadlock'
authorDavid S. Miller <davem@davemloft.net>
Wed, 18 Oct 2023 08:23:02 +0000 (09:23 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Oct 2023 08:23:02 +0000 (09:23 +0100)
commita0a86022474304e012aad5d41943fdd31a036284
tree03577f650df794602abc19036c3db14964a49e1d
parentee2a35fedbc942e6eeb9e351a53acb1fe6b101c5
parent5d77371e8c85abbe0f9fab7dacf3bc2c3214ada5
Merge branch 'devlink-deadlock'

Jiri Pirko says:

====================
devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock

devlink_port_fill() may be called sometimes with RTNL lock held.
When putting the nested port function devlink instance attrs,
current code takes nested devlink instance lock. In that case lock
ordering is wrong.

Patch #1 is a dependency of patch #2.
Patch #2 converts the peernet2id_alloc() call to rely in RCU so it could
         called without devlink instance lock.
Patch #3 takes device reference for devlink instance making sure that
         device does not disappear before devlink_release() is called.
Patch #4 benefits from the preparations done in patches #2 and #3 and
         removes the problematic nested devlink lock aquisition.
Patched #5-#7 improve documentation to reflect this issue so it is
              avoided in the future.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>