]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: remove two BUG() from skb_checksum_help()
authorEric Dumazet <edumazet@google.com>
Tue, 10 May 2022 03:57:40 +0000 (20:57 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:23:46 +0000 (09:23 +0200)
BugLink: https://bugs.launchpad.net/bugs/1981864
[ Upstream commit d7ea0d9df2a6265b2b180d17ebc64b38105968fc ]

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 <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/core/dev.c

index 5907212c00f37cf82b0d21bf67761bf226a2b844..b9731b267d073631c5593774155c4c77d823bb33 100644 (file)
@@ -3233,11 +3233,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)