Commit d7ea0d9d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: remove two BUG() from skb_checksum_help()

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66e4c8d9
...@@ -3265,11 +3265,15 @@ int skb_checksum_help(struct sk_buff *skb) ...@@ -3265,11 +3265,15 @@ int skb_checksum_help(struct sk_buff *skb)
} }
offset = skb_checksum_start_offset(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); csum = skb_checksum(skb, offset, skb->len - offset, 0);
offset += skb->csum_offset; 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)); ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment