BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Josef Bacik" <josef@toxicpanda.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/9] net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits()
Date: Wed, 07 Oct 2026 17:11:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-163218@kernel.org> (raw)
In-Reply-To: <20261006-b4-skbuff-bug-on-v1-1-1b4434c5357c@toxicpanda.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] skbuff: skb_copy_and_csum_bits() discards linear part csum on unreadable frags
--

commit 554d4ec9904f25474f32c877a62ca154d0b20324
Author: Josef Bacik <josef@toxicpanda.com>

net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits()

This commit zeroes out the remainder of a caller's buffer when
skb_copy_and_csum_bits encounters unreadable fragments. This prevents
stale uninitialized memory from being leaked when the buffer is
transmitted on the wire.

> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 5c4024a03e105..512ff9cfa269f 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3633,8 +3633,12 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
>  		pos	= copy;
>  	}
>  
> -	if (!skb_frags_readable(skb))
> +	if (!skb_frags_readable(skb)) {
> +		/* Don't hand the caller a buffer with stale bytes in it. */
> +		if (len > 0)
> +			memset(to, 0, len);
>  		return 0;

[Severity: Medium]
By returning 0 here instead of the accumulated csum, does this discard
the checksum computed for the successfully copied linear part of the packet?

When icmp_push_reply() uses skb_copy_and_csum_bits() via icmp_glue_bits()
to quote an offending packet with unreadable fragments, the offending
packet typically has its headers in the linear part. Returning 0 discards
this partial checksum.

Since the ICMP payload contains the non-zero linear part, returning 0
causes the ICMP packet's overall checksum to be computed incorrectly,
resulting in the error packet being silently dropped by the destination.

Would it be better to return csum here instead of 0, so that the checksum
is mathematically correct for the zero-padded buffer and allows the ICMP
error to be successfully delivered?

> +	}
>  
>  	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
>  		int end;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-b4-skbuff-bug-on-v1-0-1b4434c5357c@toxicpanda.com?part=1

  parent reply	other threads:[~2026-10-07 17:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 17:10 [PATCH net-next 0/9] net: skbuff: convert most BUG_ON()s to WARN_ON_ONCE() and an error Josef Bacik
2026-10-06 17:10 ` [PATCH net-next 1/9] net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits() Josef Bacik
2026-10-07 14:50   ` Willem de Bruijn
2026-10-07 17:11   ` sashiko-bot [this message]
2026-10-09  8:11   ` netdev-bot+sashiko
2026-10-06 17:10 ` [PATCH net-next 2/9] net: skbuff: don't BUG() on bad arguments to pskb_expand_head() Josef Bacik
2026-10-07 14:51   ` Willem de Bruijn
2026-10-06 17:10 ` [PATCH net-next 3/9] net: skbuff: don't BUG() on a bad frag_list layout in skb_segment() Josef Bacik
2026-10-09  8:12   ` netdev-bot+sashiko
2026-10-09 16:10   ` Mina Almasry
2026-10-06 17:10 ` [PATCH net-next 4/9] net: skbuff: don't BUG() when skb_copy_bits() fails in copy helpers Josef Bacik
2026-10-06 17:10 ` [PATCH net-next 5/9] net: skbuff: don't BUG() on leftover length in skb_checksum() and friends Josef Bacik
2026-10-09  8:12   ` netdev-bot+sashiko
2026-10-09 16:27   ` Mina Almasry
2026-10-06 17:10 ` [PATCH net-next 6/9] net: skbuff: don't BUG() on a bad csum_start in skb_copy_and_csum_dev() Josef Bacik
2026-10-09  8:12   ` netdev-bot+sashiko
2026-10-06 17:10 ` [PATCH net-next 7/9] net: skbuff: don't BUG() on leftover length in skb_copy_and_csum_bits() Josef Bacik
2026-10-07 17:11   ` sashiko-bot
2026-10-09  8:12   ` netdev-bot+sashiko
2026-10-06 17:10 ` [PATCH net-next 8/9] net: skbuff: don't BUG() on a missing head_frag in skb_zerocopy() Josef Bacik
2026-10-09  8:12   ` netdev-bot+sashiko
2026-10-09 16:11   ` Mina Almasry
2026-10-06 17:10 ` [PATCH net-next 9/9] net: skbuff: remove the BUG_ON()s from skb_shift() Josef Bacik
2026-10-07 14:48 ` [PATCH net-next 0/9] net: skbuff: convert most BUG_ON()s to WARN_ON_ONCE() and an error Willem de Bruijn
2026-10-07 14:59   ` Fernando Fernandez Mancera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-163218@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox