Skip to content

Commit fb49376

Browse files
Guillaume NaultVimalRaj
authored andcommitted
l2tp: purge socket queues in the .destruct() callback
[ Upstream commit e91793b ] The Rx path may grab the socket right before pppol2tp_release(), but nothing guarantees that it will enqueue packets before skb_queue_purge(). Therefore, the socket can be destroyed without its queues fully purged. Fix this by purging queues in pppol2tp_session_destruct() where we're guaranteed nothing is still referencing the socket. Fixes: 9e9cb62 ("l2tp: fix userspace reception on plain L2TP sockets") Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 912cae7 commit fb49376

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

net/l2tp/l2tp_ppp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ static void pppol2tp_session_close(struct l2tp_session *session)
469469
static void pppol2tp_session_destruct(struct sock *sk)
470470
{
471471
struct l2tp_session *session = sk->sk_user_data;
472+
473+
skb_queue_purge(&sk->sk_receive_queue);
474+
skb_queue_purge(&sk->sk_write_queue);
475+
472476
if (session) {
473477
sk->sk_user_data = NULL;
474478
BUG_ON(session->magic != L2TP_SESSION_MAGIC);
@@ -507,9 +511,6 @@ static int pppol2tp_release(struct socket *sock)
507511
l2tp_session_queue_purge(session);
508512
sock_put(sk);
509513
}
510-
skb_queue_purge(&sk->sk_receive_queue);
511-
skb_queue_purge(&sk->sk_write_queue);
512-
513514
release_sock(sk);
514515

515516
/* This will delete the session context via

0 commit comments

Comments
 (0)