]> Git Repo - linux.git/commitdiff
netpoll: fix NULL pointer dereference in netpoll_cleanup
authorNikolay Aleksandrov <[email protected]>
Thu, 19 Sep 2013 13:02:35 +0000 (15:02 +0200)
committerDavid S. Miller <[email protected]>
Thu, 19 Sep 2013 18:15:53 +0000 (14:15 -0400)
I've been hitting a NULL ptr deref while using netconsole because the
np->dev check and the pointer manipulation in netpoll_cleanup are done
without rtnl and the following sequence happens when having a netconsole
over a vlan and we remove the vlan while disabling the netconsole:
CPU 1 CPU2
removes vlan and calls the notifier
enters store_enabled(), calls
netdev_cleanup which checks np->dev
and then waits for rtnl
executes the netconsole netdev
release notifier making np->dev
== NULL and releases rtnl
continues to dereference a member of
np->dev which at this point is == NULL

Signed-off-by: Nikolay Aleksandrov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/core/netpoll.c

index c3c7b27c112d805cc2c2e0011501d65fddbc44d1..fc75c9e461b8d366d5c29417735432dc573f08ae 100644 (file)
@@ -1284,15 +1284,14 @@ EXPORT_SYMBOL_GPL(__netpoll_free_async);
 
 void netpoll_cleanup(struct netpoll *np)
 {
-       if (!np->dev)
-               return;
-
        rtnl_lock();
+       if (!np->dev)
+               goto out;
        __netpoll_cleanup(np);
-       rtnl_unlock();
-
        dev_put(np->dev);
        np->dev = NULL;
+out:
+       rtnl_unlock();
 }
 EXPORT_SYMBOL(netpoll_cleanup);
 
This page took 0.054293 seconds and 4 git commands to generate.