From: James Chapman Date: Mon, 29 Jul 2024 15:38:08 +0000 (+0100) Subject: l2tp: free sessions using rcu X-Git-Tag: v6.12-rc1~232^2~355^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d17e89999574aca143dd4ede43e4382d32d98724;p=thirdparty%2Flinux.git l2tp: free sessions using rcu l2tp sessions may be accessed under an rcu read lock. Have them freed via rcu and remove the now unneeded synchronize_rcu when a session is removed. Signed-off-by: James Chapman Signed-off-by: Tom Parkin Signed-off-by: David S. Miller --- diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index f6ae18c180bfb..4cf4aa2713535 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -166,7 +166,7 @@ static void l2tp_session_free(struct l2tp_session *session) trace_free_session(session); if (session->tunnel) l2tp_tunnel_dec_refcount(session->tunnel); - kfree(session); + kfree_rcu(session, rcu); } struct l2tp_tunnel *l2tp_sk_to_tunnel(const struct sock *sk) @@ -1269,8 +1269,6 @@ static void l2tp_session_unhash(struct l2tp_session *session) spin_unlock_bh(&pn->l2tp_session_idr_lock); spin_unlock_bh(&tunnel->list_lock); - - synchronize_rcu(); } } diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index 8d7a589ccd2ad..58d3977870de4 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h @@ -66,6 +66,7 @@ struct l2tp_session_coll_list { struct l2tp_session { int magic; /* should be L2TP_SESSION_MAGIC */ long dead; + struct rcu_head rcu; struct l2tp_tunnel *tunnel; /* back pointer to tunnel context */ u32 session_id;