net: fix pskb_trim_rcsum_slow() with odd trim offset
Subsystems (2)
PATCH 1/1 net: fix pskb_trim_rcsum_slow() with odd trim offset
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().
--- net/core/skbuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/core/skbuff.c +3 -2
@@ -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); }
Signature · 1 line
2.19.1.568.g152ad8e336-goog
Quoted 13 lines · 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 inpskb_trim_rcsum_slow(), introduced in commit88078d98d1bb("net:pskb_trim_rcsum()andCHECKSUM_COMPLETEare 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 withskb->csumusingcsum_sub(). We need to usecsum_block_sub()here that takes into account the parity of the start address and handles the swapping.
Quoted 4 lines
Matches existing code in
__skb_postpull_rcsum()andesp_remove_trailer().Fixes 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")Signed-off-by Dimitris Michailidis <[email protected]>
Thanks a lot Dimitris for finding this.
David Miller
maintainerFrom: Dimitris Michailidis <[email protected]>
Date: Fri, 19 Oct 2018 17:07:13 -0700
Quoted 13 lines
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 inpskb_trim_rcsum_slow(), introduced in commit88078d98d1bb("net:pskb_trim_rcsum()andCHECKSUM_COMPLETEare 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 withskb->csumusingcsum_sub(). We need to usecsum_block_sub()here that takes into account the parity of the start address and handles the swapping.
Quoted 4 lines
Matches existing code in
__skb_postpull_rcsum()andesp_remove_trailer().Fixes 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")Signed-off-by Dimitris Michailidis <[email protected]>
Applied and queued up for -stable, thanks!