You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
l2tp: unhash l2tp sessions on delete, not on free
If we postpone unhashing of l2tp sessions until the structure is freed, we
risk:
1. further packets arriving and getting queued while the pseudowire is being
closed down
2. the recv path hitting "scheduling while atomic" errors in the case that
recv drops the last reference to a session and calls l2tp_session_free
while in atomic context
As such, l2tp sessions should be unhashed from l2tp_core data structures early
in the teardown process prior to calling pseudowire close. For pseudowires
like l2tp_ppp which have multiple shutdown codepaths, provide an unhash hook.
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
7b7c0719cd
commit
f6e16b299b
+3
-9
@@ -466,19 +466,12 @@ static void pppol2tp_session_close(struct l2tp_session *session)
|
||||
*/
|
||||
static void pppol2tp_session_destruct(struct sock *sk)
|
||||
{
|
||||
struct l2tp_session *session;
|
||||
|
||||
if (sk->sk_user_data != NULL) {
|
||||
session = sk->sk_user_data;
|
||||
if (session == NULL)
|
||||
goto out;
|
||||
|
||||
struct l2tp_session *session = sk->sk_user_data;
|
||||
if (session) {
|
||||
sk->sk_user_data = NULL;
|
||||
BUG_ON(session->magic != L2TP_SESSION_MAGIC);
|
||||
l2tp_session_dec_refcount(session);
|
||||
}
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -509,6 +502,7 @@ static int pppol2tp_release(struct socket *sock)
|
||||
|
||||
/* Purge any queued data */
|
||||
if (session != NULL) {
|
||||
__l2tp_session_unhash(session);
|
||||
l2tp_session_queue_purge(session);
|
||||
sock_put(sk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user