Skip to contentSkip to conversation

Patch "net: Fix skb csum races when peeking" has been added to the 3.14-stable tree

PATCH [email protected] 1 participant 1 message Sep 26, 2015

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net: Fix skb csum races when peeking

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-fix-skb-csum-races-when-peeking.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Sat Sep 26 11:19:08 PDT 2015

From: Herbert Xu <[email protected]>
Date: Mon, 13 Jul 2015 20:01:42 +0800
Subject: net: Fix skb csum races when peeking

From: Herbert Xu <[email protected]>

[ Upstream commit 89c22d8c3b278212eef6a8cc66b570bc840a6f5a ]

When we calculate the checksum on the recv path, we store the result in the skb as an optimisation in case we need the checksum again down the line.

This is in fact bogus for the MSG_PEEK case as this is done without any locking. So multiple threads can peek and then store the result to the same skb, potentially resulting in bogus skb states.

This patch fixes this by only storing the result if the skb is not shared. This preserves the optimisations for the few cases where it can be done safely due to locking or other reasons, e.g., SIOCINQ.

---
 net/core/datagram.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/datagram.c +2 -1
@@ -777,7 +777,8 @@ __sum16 __skb_checksum_complete_head(str
 	if (likely(!sum)) {
 		if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
 			netdev_rx_csum_fault(skb->dev);
-		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		if (!skb_shared(skb))
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
 	}
 	return sum;
 }

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/net-fix-skb_set_peeked-use-after-free-bug.patch queue-3.14/ipv6-lock-socket-in-ip6_datagram_connect.patch queue-3.14/net-fix-skb-csum-races-when-peeking.patch queue-3.14/net-clone-skb-before-setting-peeked-flag.patch