]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - drivers/net/ppp/ppp_generic.c
ppp: prevent unregistered channels from connecting to PPP units
authorGuillaume Nault <g.nault@alphalink.fr>
Fri, 2 Mar 2018 17:41:16 +0000 (18:41 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 15 Mar 2018 13:27:55 +0000 (08:27 -0500)
commit2f23ff17205d8cd23dad7509848cb06b630bcbeb
tree7e6b4e12397a164ad5b8abf6118f17bf5f7edff4
parent4c7dcb53d76307b4a7c885a78dee59888ae681e5
ppp: prevent unregistered channels from connecting to PPP units

BugLink: http://bugs.launchpad.net/bugs/1755179
[ Upstream commit 77f840e3e5f09c6d7d727e85e6e08276dd813d11 ]

PPP units don't hold any reference on the channels connected to it.
It is the channel's responsibility to ensure that it disconnects from
its unit before being destroyed.
In practice, this is ensured by ppp_unregister_channel() disconnecting
the channel from the unit before dropping a reference on the channel.

However, it is possible for an unregistered channel to connect to a PPP
unit: register a channel with ppp_register_net_channel(), attach a
/dev/ppp file to it with ioctl(PPPIOCATTCHAN), unregister the channel
with ppp_unregister_channel() and finally connect the /dev/ppp file to
a PPP unit with ioctl(PPPIOCCONNECT).

Once in this situation, the channel is only held by the /dev/ppp file,
which can be released at anytime and free the channel without letting
the parent PPP unit know. Then the ppp structure ends up with dangling
pointers in its ->channels list.

Prevent this scenario by forbidding unregistered channels from
connecting to PPP units. This maintains the code logic by keeping
ppp_unregister_channel() responsible from disconnecting the channel if
necessary and avoids modification on the reference counting mechanism.

This issue seems to predate git history (successfully reproduced on
Linux 2.6.26 and earlier PPP commits are unrelated).

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/net/ppp/ppp_generic.c