All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset
@ 2018-10-20  0:07 Dimitris Michailidis
  2018-10-20  0:13 ` Eric Dumazet
  2018-10-20  8:14 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Dimitris Michailidis @ 2018-10-20  0:07 UTC (permalink / raw)
  To: edumazet, davem; +Cc: netdev, Dimitris Michailidis

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 88078d98d1bb
("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: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")
Signed-off-by: Dimitris Michailidis <dmichail@google.com>
---
 net/core/skbuff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 428094b577fc..f817f336595d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1846,8 +1846,9 @@ int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
 	if (skb->ip_summed == CHECKSUM_COMPLETE) {
 		int delta = skb->len - len;
 
-		skb->csum = csum_sub(skb->csum,
-				     skb_checksum(skb, len, delta, 0));
+		skb->csum = csum_block_sub(skb->csum,
+					   skb_checksum(skb, len, delta, 0),
+					   len);
 	}
 	return __pskb_trim(skb, len);
 }
-- 
2.19.1.568.g152ad8e336-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset
  2018-10-20  0:07 [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset Dimitris Michailidis
@ 2018-10-20  0:13 ` Eric Dumazet
  2018-10-20  8:14 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2018-10-20  0:13 UTC (permalink / raw)
  To: Dimitris Michailidis, edumazet, davem; +Cc: netdev



On 10/19/2018 05:07 PM, Dimitris Michailidis wrote:
> 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 88078d98d1bb
> ("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: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")
> Signed-off-by: Dimitris Michailidis <dmichail@google.com>

Thanks a lot Dimitris for finding this.

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset
  2018-10-20  0:07 [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset Dimitris Michailidis
  2018-10-20  0:13 ` Eric Dumazet
@ 2018-10-20  8:14 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-10-20  8:14 UTC (permalink / raw)
  To: dmichail; +Cc: edumazet, netdev

From: Dimitris Michailidis <dmichail@google.com>
Date: Fri, 19 Oct 2018 17:07:13 -0700

> 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 88078d98d1bb
> ("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: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")
> Signed-off-by: Dimitris Michailidis <dmichail@google.com>

Applied and queued up for -stable, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-20 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20  0:07 [PATCH net] net: fix pskb_trim_rcsum_slow() with odd trim offset Dimitris Michailidis
2018-10-20  0:13 ` Eric Dumazet
2018-10-20  8:14 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.