diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-11-02 18:47:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-03 18:02:13 -0400 |
commit | e2e210c0238eb7073e07af503ae743fa53977120 (patch) | |
tree | a4940a436eb0292f09a9e9c09d7bfccfc5a0d76f /net | |
parent | 2edcd4ca43df3c1d1d392753531cc73a53e709ba (diff) |
l2tp: fix race in l2tp_recv_dequeue()
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 <spiked.yar@gmail.com>
Tested-by: Misha Labjuk <spiked.yar@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/l2tp/l2tp_core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 34b2ddeacb67..bf8d50c67931 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -397,6 +397,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session) | |||
397 | * expect to send up next, dequeue it and any other | 397 | * expect to send up next, dequeue it and any other |
398 | * in-sequence packets behind it. | 398 | * in-sequence packets behind it. |
399 | */ | 399 | */ |
400 | start: | ||
400 | spin_lock_bh(&session->reorder_q.lock); | 401 | spin_lock_bh(&session->reorder_q.lock); |
401 | skb_queue_walk_safe(&session->reorder_q, skb, tmp) { | 402 | skb_queue_walk_safe(&session->reorder_q, skb, tmp) { |
402 | if (time_after(jiffies, L2TP_SKB_CB(skb)->expires)) { | 403 | if (time_after(jiffies, L2TP_SKB_CB(skb)->expires)) { |
@@ -433,7 +434,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session) | |||
433 | */ | 434 | */ |
434 | spin_unlock_bh(&session->reorder_q.lock); | 435 | spin_unlock_bh(&session->reorder_q.lock); |
435 | l2tp_recv_dequeue_skb(session, skb); | 436 | l2tp_recv_dequeue_skb(session, skb); |
436 | spin_lock_bh(&session->reorder_q.lock); | 437 | goto start; |
437 | } | 438 | } |
438 | 439 | ||
439 | out: | 440 | out: |