Skip to content

Commit d7ea0d9

Browse files
edumazetdavem330
authored andcommitted
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: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 66e4c8d commit d7ea0d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/core/dev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,11 +3265,15 @@ int skb_checksum_help(struct sk_buff *skb)
32653265
}
32663266

32673267
offset = skb_checksum_start_offset(skb);
3268-
BUG_ON(offset >= skb_headlen(skb));
3268+
ret = -EINVAL;
3269+
if (WARN_ON_ONCE(offset >= skb_headlen(skb)))
3270+
goto out;
3271+
32693272
csum = skb_checksum(skb, offset, skb->len - offset, 0);
32703273

32713274
offset += skb->csum_offset;
3272-
BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
3275+
if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb)))
3276+
goto out;
32733277

32743278
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
32753279
if (ret)

0 commit comments

Comments
 (0)