提交 eaadd14b 编写于 作者: E Eric Dumazet 提交者: Zheng Zengkai

net: remove two BUG() from skb_checksum_help()

stable inclusion
from stable-v5.10.121
commit 312c43e98ed190bd8fd7a71a0addf9539d5b8ab1
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=312c43e98ed190bd8fd7a71a0addf9539d5b8ab1

--------------------------------

[ Upstream commit d7ea0d9d ]

I have a syzbot report that managed to get a crash in skb_checksum_help()

If syzbot can trigger these BUG(), it makes sense to replace
them with more friendly WARN_ON_ONCE() since skb_checksum_help()
can instead return an error code.

Note that syzbot will still crash there, until real bug is fixed.
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 c8c479f1
......@@ -3242,11 +3242,15 @@ int skb_checksum_help(struct sk_buff *skb)
}
offset = skb_checksum_start_offset(skb);
BUG_ON(offset >= skb_headlen(skb));
ret = -EINVAL;
if (WARN_ON_ONCE(offset >= skb_headlen(skb)))
goto out;
csum = skb_checksum(skb, offset, skb->len - offset, 0);
offset += skb->csum_offset;
BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb)))
goto out;
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册