l2tp: hold tunnel while handling genl TUNNEL_GET commands
authorGuillaume Nault <g.nault@alphalink.fr>
Fri, 25 Aug 2017 14:51:43 +0000 (16:51 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Nov 2017 13:34:34 +0000 (13:34 +0000)
commit37e611e909ecc247cb6a3cfa4b9bd74235025b00
tree3c07ff82a88167a7c0c04e995c70f0af02caf7e6
parenta8f8415ccfd9d3cc99eef6342eb1f0e990e8347b
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>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/l2tp/l2tp_netlink.c