ppp: unlock all_ppp_mutex before registering device
authorGuillaume Nault <g.nault@alphalink.fr>
Wed, 10 Jan 2018 15:24:45 +0000 (16:24 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Jan 2018 18:22:03 +0000 (13:22 -0500)
commit0171c41835591e9aa2e384b703ef9a6ae367c610
tree20152d441d0eec300ca4f4e98b013b1d762fc955
parent66940f35d5a81d5969bb5543171c70a434fc5110
ppp: unlock all_ppp_mutex before registering device

ppp_dev_uninit(), which is the .ndo_uninit() handler of PPP devices,
needs to lock pn->all_ppp_mutex. Therefore we mustn't call
register_netdevice() with pn->all_ppp_mutex already locked, or we'd
deadlock in case register_netdevice() fails and calls .ndo_uninit().

Fortunately, we can unlock pn->all_ppp_mutex before calling
register_netdevice(). This lock protects pn->units_idr, which isn't
used in the device registration process.

However, keeping pn->all_ppp_mutex locked during device registration
did ensure that no device in transient state would be published in
pn->units_idr. In practice, unlocking it before calling
register_netdevice() doesn't change this property: ppp_unit_register()
is called with 'ppp_mutex' locked and all searches done in
pn->units_idr hold this lock too.

Fixes: 8cb775bc0a34 ("ppp: fix device unregistration upon netns deletion")
Reported-and-tested-by: syzbot+367889b9c9e279219175@syzkaller.appspotmail.com
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ppp/ppp_generic.c