LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Dimitris Michailidis <dmichail@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.9 12/13] net: fix pskb_trim_rcsum_slow() with odd trim offset
Date: Tue, 30 Oct 2018 09:29:22 -0400	[thread overview]
Message-ID: <20181030132923.218124-12-sashal@kernel.org> (raw)
In-Reply-To: <20181030132923.218124-1-sashal@kernel.org>

From: Dimitris Michailidis <dmichail@google.com>

[ Upstream commit d55bef5059dd057bd077155375c581b49d25be7e ]

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>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 038ec74fa131..68ecb7d71c2b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1585,8 +1585,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.17.1


  parent reply	other threads:[~2018-10-30 13:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 13:29 [PATCH AUTOSEL 4.9 01/13] bpf: do not blindly change rlimit in reuseport net selftest Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 02/13] Revert "perf tools: Fix PMU term format max value calculation" Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 03/13] xfrm: policy: use hlist rcu variants on insert Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 04/13] sparc: Fix single-pcr perf event counter management Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 05/13] sparc64: Make proc_id signed Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 06/13] sched/fair: Fix the min_vruntime update logic in dequeue_entity() Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 07/13] perf cpu_map: Align cpu map synthesized events properly Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 08/13] x86/fpu: Remove second definition of fpu in __fpu__restore_sig() Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 09/13] net: qla3xxx: Remove overflowing shift statement Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 10/13] r8169: fix NAPI handling under high load Sasha Levin
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 11/13] selftests: ftrace: Add synthetic event syntax testcase Sasha Levin
2018-10-30 13:29 ` Sasha Levin [this message]
2018-10-30 13:29 ` [PATCH AUTOSEL 4.9 13/13] i2c: rcar: cleanup DMA for all kinds of failure Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181030132923.218124-12-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dmichail@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --subject='Re: [PATCH AUTOSEL 4.9 12/13] net: fix pskb_trim_rcsum_slow() with odd trim offset' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).