diff mbox series

[net] net: refine debug info in skb_checksum_help()

Message ID 20231006173355.2254983-1-edumazet@google.com (mailing list archive)
State Accepted
Commit 26c29961b142444cd99361644c30fa1e9b3da6be
Delegated to: Netdev Maintainers
Headers show
Series [net] net: refine debug info in skb_checksum_help() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1371 this patch: 1371
netdev/cc_maintainers warning 1 maintainers not CCed: daniel@iogearbox.net
netdev/build_clang fail Errors and warnings before: 17 this patch: 17
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 23 this patch: 23
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet Oct. 6, 2023, 5:33 p.m. UTC
syzbot uses panic_on_warn.

This means that the skb_dump() I added in the blamed commit are
not even called.

Rewrite this so that we get the needed skb dump before syzbot crashes.

Fixes: eeee4b77dc52 ("net: add more debug info in skb_checksum_help()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Willem de Bruijn <willemb@google.com>
---
 net/core/dev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Willem de Bruijn Oct. 7, 2023, 8:53 a.m. UTC | #1
On Fri, Oct 6, 2023 at 12:34 PM Eric Dumazet <edumazet@google.com> wrote:
>
> syzbot uses panic_on_warn.
>
> This means that the skb_dump() I added in the blamed commit are
> not even called.
>
> Rewrite this so that we get the needed skb dump before syzbot crashes.
>
> Fixes: eeee4b77dc52 ("net: add more debug info in skb_checksum_help()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Willem de Bruijn <willemb@google.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>
patchwork-bot+netdevbpf@kernel.org Oct. 10, 2023, 2:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  6 Oct 2023 17:33:54 +0000 you wrote:
> syzbot uses panic_on_warn.
> 
> This means that the skb_dump() I added in the blamed commit are
> not even called.
> 
> Rewrite this so that we get the needed skb dump before syzbot crashes.
> 
> [...]

Here is the summary with links:
  - [net] net: refine debug info in skb_checksum_help()
    https://git.kernel.org/netdev/net/c/26c29961b142

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 85df22f05c38b663f050410b9f7bcd32dd781951..5aaf5753d4e46c7c4b67b00daadeda9784708dfe 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3292,15 +3292,19 @@  int skb_checksum_help(struct sk_buff *skb)
 
 	offset = skb_checksum_start_offset(skb);
 	ret = -EINVAL;
-	if (WARN_ON_ONCE(offset >= skb_headlen(skb))) {
+	if (unlikely(offset >= skb_headlen(skb))) {
 		DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
+		WARN_ONCE(true, "offset (%d) >= skb_headlen() (%u)\n",
+			  offset, skb_headlen(skb));
 		goto out;
 	}
 	csum = skb_checksum(skb, offset, skb->len - offset, 0);
 
 	offset += skb->csum_offset;
-	if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb))) {
+	if (unlikely(offset + sizeof(__sum16) > skb_headlen(skb))) {
 		DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
+		WARN_ONCE(true, "offset+2 (%zu) > skb_headlen() (%u)\n",
+			  offset + sizeof(__sum16), skb_headlen(skb));
 		goto out;
 	}
 	ret = skb_ensure_writable(skb, offset + sizeof(__sum16));