]> git.baikalelectronics.ru Git - kernel.git/commit
l2tp: fix use-after-free during module unload
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 2 Sep 2016 08:22:54 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Sep 2016 18:44:44 +0000 (11:44 -0700)
commite847d2d80d52071be836b86dab4256e44a37446c
tree52019189807bf0a51f0c45638403dbbabd1e7328
parente2d12e3246c4d27eb093f47ddfff8e6a11559444
l2tp: fix use-after-free during module unload

Tunnel deletion is delayed by both a workqueue (l2tp_tunnel_delete -> wq
 -> l2tp_tunnel_del_work) and RCU (sk_destruct -> RCU ->
l2tp_tunnel_destruct).

By the time l2tp_tunnel_destruct() runs to destroy the tunnel and finish
destroying the socket, the private data reserved via the net_generic
mechanism has already been freed, but l2tp_tunnel_destruct() actually
uses this data.

Make sure tunnel deletion for the netns has completed before returning
from l2tp_exit_net() by first flushing the tunnel removal workqueue, and
then waiting for RCU callbacks to complete.

Fixes: 9c6dc710ba16 ("l2tp: create tunnel sockets in the right namespace")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_core.c