l2tp: hold tunnel while handling genl TUNNEL_GET commands
authorGuillaume Nault <g.nault@alphalink.fr>
Thu, 21 May 2020 23:39:29 +0000 (00:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 May 2020 14:41:57 +0000 (16:41 +0200)
commit4c15cdb962d27d5b095fd444156c0746993df377
treed7f9cea8abb07cf1ecb0a3497b21836186956345
parent00cf4055d5a14584833a2b355d846a56f74ce96b
l2tp: hold tunnel while handling genl TUNNEL_GET commands

commit 4e4b21da3acc68a7ea55f850cacc13706b7480e9 upstream.

Use l2tp_tunnel_get() instead of l2tp_tunnel_find() so that we get
a reference on the tunnel, preventing l2tp_tunnel_destruct() from
freeing it from under us.

Also move l2tp_tunnel_get() below nlmsg_new() so that we only take
the reference when needed.

Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/l2tp/l2tp_netlink.c