Skip to content

Commit

Permalink
netconsole: fix a deadlock with rtnl and netconsole's mutex
Browse files Browse the repository at this point in the history
This bug was introduced by commit
7a163bf ("netconsole: avoid a crash with
multiple sysfs writers"). In store_enabled() we have the following
sequence: acquire nt->mutex then rtnl, but in the netconsole netdev
notifier we have rtnl then nt->mutex effectively leading to a deadlock.
The NULL pointer dereference that the above commit tries to fix is
actually due to another bug in netpoll_cleanup(). This is fixed by dropping
the mutex from the netdev notifier as it's already protected by rtnl.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Sep 19, 2013
1 parent d0fe8c8 commit c71380f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/net/netconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,12 @@ static int netconsole_netdev_event(struct notifier_block *this,
case NETDEV_RELEASE:
case NETDEV_JOIN:
case NETDEV_UNREGISTER:
/*
* rtnl_lock already held
/* rtnl_lock already held
* we might sleep in __netpoll_cleanup()
*/
spin_unlock_irqrestore(&target_list_lock, flags);

mutex_lock(&nt->mutex);
__netpoll_cleanup(&nt->np);
mutex_unlock(&nt->mutex);

spin_lock_irqsave(&target_list_lock, flags);
dev_put(nt->np.dev);
Expand Down

0 comments on commit c71380f

Please sign in to comment.