[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <7080e8a3-6eaa-e9e1-afd8-b1eef38d1e89@virtuozzo.com>
Date: Fri, 11 Dec 2020 18:00:55 +0300
From: Vasily Averin <vvs@...tuozzo.com>
To: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org
Subject: [PATCH] net: check skb partial checksum offset after trim
syzkaller reproduces BUG_ON in skb_checksum_help():
tun creates skb with big partial checksum area and small ip packet inside,
then ip_rcv() decreases skb size of below length of checksummed area,
then checksum_tg() called via netfilter hook detects incorrect skb:
offset = skb_checksum_start_offset(skb);
BUG_ON(offset >= skb_headlen(skb));
This patch drops CHEKSUM_PARTIAL mark when skb is trimmed below
size of checksummed area.
Link: https://syzkaller.appspot.com/bug?id=b419a5ca95062664fe1a60b764621eb4526e2cd0
Reported-by: syzbot+7010af67ced6105e5ab6@...kaller.appspotmail.com
Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
---
include/linux/skbuff.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a828cf9..0a9545d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3419,9 +3419,18 @@ static inline void *skb_push_rcsum(struct sk_buff *skb, unsigned int len)
static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
{
+ int ret;
+
if (likely(len >= skb->len))
return 0;
- return pskb_trim_rcsum_slow(skb, len);
+ ret = pskb_trim_rcsum_slow(skb, len);
+ if (!ret && (skb->ip_summed == CHECKSUM_PARTIAL)) {
+ int offset = skb_checksum_start_offset(skb) + skb->csum_offset;
+
+ if (offset + sizeof(__sum16) > skb_headlen(skb))
+ skb->ip_summed = CHECKSUM_NONE;
+ }
+ return ret;
}
static inline int __skb_trim_rcsum(struct sk_buff *skb, unsigned int len)
--
1.8.3.1
Powered by blists - more mailing lists