Skip to content

Commit 855cb69

Browse files
dimichailgregkh
authored andcommitted
net: fix pskb_trim_rcsum_slow() with odd trim offset
[ Upstream commit d55bef5 ] We've been getting checksum errors involving small UDP packets, usually 59B packets with 1 extra non-zero padding byte. netdev_rx_csum_fault() has been complaining that HW is providing bad checksums. Turns out the problem is in pskb_trim_rcsum_slow(), introduced in commit 88078d9 ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"). The source of the problem is that when the bytes we are trimming start at an odd address, as in the case of the 1 padding byte above, skb_checksum() returns a byte-swapped value. We cannot just combine this with skb->csum using csum_sub(). We need to use csum_block_sub() here that takes into account the parity of the start address and handles the swapping. Matches existing code in __skb_postpull_rcsum() and esp_remove_trailer(). Fixes: 88078d9 ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends") Signed-off-by: Dimitris Michailidis <dmichail@google.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 623670a commit 855cb69

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

net/core/skbuff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,8 +1843,9 @@ int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
18431843
if (skb->ip_summed == CHECKSUM_COMPLETE) {
18441844
int delta = skb->len - len;
18451845

1846-
skb->csum = csum_sub(skb->csum,
1847-
skb_checksum(skb, len, delta, 0));
1846+
skb->csum = csum_block_sub(skb->csum,
1847+
skb_checksum(skb, len, delta, 0),
1848+
len);
18481849
}
18491850
return __pskb_trim(skb, len);
18501851
}

0 commit comments

Comments
 (0)