From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>, Eric Dumazet <edumazet@google.com>
Subject: [Patch net] net: make pskb_trim_rcsum_slow() robust
Date: Mon, 29 Oct 2018 17:35:15 -0700 [thread overview]
Message-ID: <20181030003515.12075-1-xiyou.wangcong@gmail.com> (raw)
Most callers of pskb_trim_rcsum() simply drops the skb when
it fails, however, ip_check_defrag() still continues to pass
the skb up to stack. In that case, we should restore its previous
csum if __pskb_trim() fails.
Found this during code review.
Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/core/skbuff.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 946de0e24c87..5decd6e6d2b6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1843,6 +1843,9 @@ EXPORT_SYMBOL(___pskb_trim);
*/
int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
{
+ __wsum old_csum = skb->csum;
+ int ret;
+
if (skb->ip_summed == CHECKSUM_COMPLETE) {
int delta = skb->len - len;
@@ -1850,7 +1853,10 @@ int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
skb_checksum(skb, len, delta, 0),
len);
}
- return __pskb_trim(skb, len);
+ ret = __pskb_trim(skb, len);
+ if (unlikely(ret))
+ skb->csum = old_csum;
+ return ret;
}
EXPORT_SYMBOL(pskb_trim_rcsum_slow);
--
2.16.4
next reply other threads:[~2018-10-30 9:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 0:35 Cong Wang [this message]
2018-10-30 2:14 ` [Patch net] net: make pskb_trim_rcsum_slow() robust Eric Dumazet
2018-10-30 2:21 ` Cong Wang
2018-10-30 2:25 ` Eric Dumazet
2018-10-30 2:41 ` Cong Wang
2018-10-30 3:08 ` Eric Dumazet
2018-10-30 18:57 ` Cong Wang
2018-10-31 19:36 ` David Miller
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=20181030003515.12075-1-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox