]> git.baikalelectronics.ru Git - kernel.git/commit
l2tp: hold reference on tunnels in netlink dumps
authorGuillaume Nault <g.nault@alphalink.fr>
Thu, 12 Apr 2018 18:50:33 +0000 (20:50 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 13 Apr 2018 16:17:26 +0000 (12:17 -0400)
commit93aa1e925fb97eb6c1dc69a71f15e0cb3c4c43b3
treed8bbddb871da06b66202ebaf67527dcb3267f19b
parentbe9f43dd5f342776770307e3ae76f537db3a364c
l2tp: hold reference on tunnels in netlink dumps

l2tp_tunnel_find_nth() is unsafe: no reference is held on the returned
tunnel, therefore it can be freed whenever the caller uses it.
This patch defines l2tp_tunnel_get_nth() which works similarly, but
also takes a reference on the returned tunnel. The caller then has to
drop it after it stops using the tunnel.

Convert netlink dumps to make them safe against concurrent tunnel
deletion.

Fixes: 654563a37b6e ("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>
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h
net/l2tp/l2tp_netlink.c