l2tp: hold tunnel while handling genl TUNNEL_GET commands
authorGuillaume Nault <g.nault@alphalink.fr>
Thu, 21 May 2020 23:57:32 +0000 (00:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 May 2020 14:40:31 +0000 (16:40 +0200)
commit57cf7aa66fb7b3ec4a3c5f31c996944233addcba
tree9b259b7fc73842cca379b986c300ed0b6e897dc3
parenteb34471f73dafc9cda27226cdf3fbafde5f04470
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