On Monday, June 13, 2016 07:41:30 Sven Eckelmann wrote:
The legacy sysfs interface to modify interfaces belonging to batman-adv is run inside a region holding s_lock. And to add a net_device, it has to also get the rtnl_lock. This is exactly the other way around than in other virtual net_devices and conflicts with netdevice notifier which executes inside rtnl_lock.
The inverted lock situation is currently solved by executing the removal of netdevices via workqueue. The workqueue isn't executed inside rtnl_lock and thus can independently get the s_lock and the rtnl_lock.
But this workaround fails when the netdevice notifier creates events in quick succession and the earlier triggered removal of a net_device isn't processed in the workqueue before the adding of the new netdevice (with same name) event is issued.
Instead the legacy sysfs interface store events have to be enqueued in a workqueue to loose the s_lock. The worker is then free to get the required locks and the deadlock is avoided.
Signed-off-by: Sven Eckelmann sven@narfation.org
v5:
- rebase on top of current master
v4:
- rebase on top of current master
v3:
- rebased on top of current master to fix conflicts with newest patches
v2:
- rebased on top of current master to fix conflicts with newest patches
net/batman-adv/sysfs.c | 107 +++++++++++++++++++++++++++++++++++++------------ net/batman-adv/types.h | 13 ++++++ 2 files changed, 94 insertions(+), 26 deletions(-)
Applied in revision a1f0a80.
Thanks, Marek