Skip to contentSkip to conversation

tipc: fix bug in socket reception function

PATCH Applied Jon Maloy 2 participants 2 messages Feb 8, 2015

Subsystems (3)
lore
Share & tools
lore

Jon Maloy

author
#0 lore raw

PATCH 1/1 tipc: fix bug in socket reception function

In commit c637c1035534867b85b78b453c38c495b58e2c5a ("tipc: resolve race problem at unicast message reception") we introduced a time limit for how long the function tipc_sk_eneque() would be allowed to execute its loop. Unfortunately, the test for when this limit is passed was put in the wrong place, resulting in a lost message when the test is true.

We fix this by moving the test to before we dequeue the next buffer from the input queue.

---
 net/tipc/socket.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/tipc/socket.c +2 -3
index 6666680..4a98d15 100644
@@ -1802,12 +1802,11 @@ static int tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
 	unsigned long time_limit = jiffies + 2;
 
 	while (skb_queue_len(inputq)) {
+		if (unlikely(time_after_eq(jiffies, time_limit)))
+			return TIPC_OK;
 		skb = tipc_skb_dequeue(inputq, dport);
 		if (unlikely(!skb))
 			return TIPC_OK;
-		/* Return if softirq window exhausted */
-		if (unlikely(time_after_eq(jiffies, time_limit)))
-			return TIPC_OK;
 		if (!sock_owned_by_user(sk)) {
 			err = filter_rcv(sk, &skb);
 			if (likely(!skb))
Signature · 1 line
1.9.1
maintainer Applied
#1 lore raw

From: Jon Maloy <[email protected]>
Date: Sun, 8 Feb 2015 11:10:50 -0500

Quoted 10 lines

In commit c637c1035534867b85b78b453c38c495b58e2c5a ("tipc: resolve race problem at unicast message reception") we introduced a time limit for how long the function tipc_sk_eneque() would be allowed to execute its loop. Unfortunately, the test for when this limit is passed was put in the wrong place, resulting in a lost message when the test is true.

We fix this by moving the test to before we dequeue the next buffer from the input queue.

Applied, thanks Jon.