Skip to content

Commit

Permalink
l2tp: fix race in l2tp_recv_dequeue()
Browse files Browse the repository at this point in the history
Misha Labjuk reported panics occurring in l2tp_recv_dequeue()

If we release reorder_q.lock, we must not keep a dangling pointer (tmp),
since another thread could manipulate reorder_q.

Instead we must restart the scan at beginning of list.

Reported-by: Misha Labjuk <[email protected]>
Tested-by: Misha Labjuk <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Nov 3, 2011
1 parent 2edcd4c commit e2e210c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session)
* expect to send up next, dequeue it and any other
* in-sequence packets behind it.
*/
start:
spin_lock_bh(&session->reorder_q.lock);
skb_queue_walk_safe(&session->reorder_q, skb, tmp) {
if (time_after(jiffies, L2TP_SKB_CB(skb)->expires)) {
Expand Down Expand Up @@ -433,7 +434,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session)
*/
spin_unlock_bh(&session->reorder_q.lock);
l2tp_recv_dequeue_skb(session, skb);
spin_lock_bh(&session->reorder_q.lock);
goto start;
}

out:
Expand Down

0 comments on commit e2e210c

Please sign in to comment.