]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
l2tp: free sessions using rcu
authorJames Chapman <jchapman@katalix.com>
Mon, 29 Jul 2024 15:38:08 +0000 (16:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2024 10:03:11 +0000 (12:03 +0200)
[ Upstream commit d17e89999574aca143dd4ede43e4382d32d98724 ]

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 <jchapman@katalix.com>
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h

index a9cbcbc9d016d246ec2411cf213ff8b3d9bba491..edff7afc06199d84caf4da79034e9cff27ebad76 100644 (file)
@@ -152,7 +152,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(struct sock *sk)
@@ -1298,8 +1298,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();
        }
 }
 
index 6c25c196cc2224ffa811cf3a699d887db8861ac1..d0e3460089d90253bad063f44b95e3401e2aefab 100644 (file)
@@ -67,6 +67,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;