linux/net/l2tp
James Chapman 24256415d1 l2tp: prevent possible tunnel refcount underflow
When a session is created, it sets a backpointer to its tunnel. When
the session refcount drops to 0, l2tp_session_free drops the tunnel
refcount if session->tunnel is non-NULL. However, session->tunnel is
set in l2tp_session_create, before the tunnel refcount is incremented
by l2tp_session_register, which leaves a small window where
session->tunnel is non-NULL when the tunnel refcount hasn't been
bumped.

Moving the assignment to l2tp_session_register is trivial but
l2tp_session_create calls l2tp_session_set_header_len which uses
session->tunnel to get the tunnel's encap. Add an encap arg to
l2tp_session_set_header_len to avoid using session->tunnel.

If l2tpv3 sessions have colliding IDs, it is possible for
l2tp_v3_session_get to race with l2tp_session_register and fetch a
session which doesn't yet have session->tunnel set. Add a check for
this case.

Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2024-07-31 09:25:13 +01:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
l2tp_core.c l2tp: prevent possible tunnel refcount underflow 2024-07-31 09:25:13 +01:00
l2tp_core.h l2tp: prevent possible tunnel refcount underflow 2024-07-31 09:25:13 +01:00
l2tp_debugfs.c l2tp: replace hlist with simple list for per-tunnel session list 2024-06-21 11:33:34 +01:00
l2tp_eth.c net l2tp: drop flow hash on forward 2024-04-26 13:48:24 +02:00
l2tp_ip6.c l2tp: lookup tunnel from socket without using sk_user_data 2024-07-31 09:25:12 +01:00
l2tp_ip.c l2tp: have l2tp_ip_destroy_sock use ip_flush_pending_frames 2024-07-31 09:25:12 +01:00
l2tp_netlink.c l2tp: prevent possible tunnel refcount underflow 2024-07-31 09:25:13 +01:00
l2tp_ppp.c l2tp: prevent possible tunnel refcount underflow 2024-07-31 09:25:13 +01:00
Makefile l2tp: add tracepoint infrastructure to core 2020-08-22 12:44:37 -07:00
trace.h l2tp: add tracepoint definitions in trace.h 2020-08-22 12:44:37 -07:00