]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
ppp: fix device unregistration upon netns deletion
authorGuillaume Nault <g.nault@alphalink.fr>
Fri, 14 Aug 2015 08:42:56 +0000 (10:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Aug 2015 19:22:20 +0000 (12:22 -0700)
commit8cb775bc0a34dc596837e7da03fd22c747be618b
tree976085da3c0312a219d1a479ff28280d1ad0b751
parent11e122cbe90ea5079622fb57bdf2dffe8cf68e57
ppp: fix device unregistration upon netns deletion

PPP devices may get automatically unregistered when their network
namespace is getting removed. This happens if the ppp control plane
daemon (e.g. pppd) exits while it is the last user of this namespace.

This leads to several races:

  * ppp_exit_net() may destroy the per namespace idr (pn->units_idr)
    before all file descriptors were released. Successive ppp_release()
    calls may then cleanup PPP devices with ppp_shutdown_interface() and
    try to use the already destroyed idr.

  * Automatic device unregistration may also happen before the
    ppp_release() call for that device gets executed. Once called on
    the file owning the device, ppp_release() will then clean it up and
    try to unregister it a second time.

To fix these issues, operations defined in ppp_shutdown_interface() are
moved to the PPP device's ndo_uninit() callback. This allows PPP
devices to be properly cleaned up by unregister_netdev() and friends.
So checking for ppp->owner is now an accurate test to decide if a PPP
device should be unregistered.

Setting ppp->owner is done in ppp_create_interface(), before device
registration, in order to avoid unprotected modification of this field.

Finally, ppp_exit_net() now starts by unregistering all remaining PPP
devices to ensure that none will get unregistered after the call to
idr_destroy().

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ppp/ppp_generic.c