From: Eric Dumazet Date: Wed, 2 Nov 2011 22:47:44 +0000 (+0000) Subject: l2tp: fix race in l2tp_recv_dequeue() X-Git-Tag: upstream/snapshot3+hdmi~8828^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2e210c0238eb7073e07af503ae743fa53977120;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Tested-by: Misha Labjuk Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 34b2dde..bf8d50c 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) * 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)) { @@ -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: