From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf 1/2] bpf: Fix bpf_skb_change_tail wrt csum partial skbs
Date: Mon, 07 Sep 2026 12:24:14 +0000 [thread overview]
Message-ID: <20260907122414.95F7F1F00ACF@smtp.kernel.org> (raw)
In-Reply-To: <20260907121025.1923656-1-daniel@iogearbox.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The checksum field space check in `bpf_skb_trim_rcsum()` assumes a 2-byte checksum (`sizeof(__sum16)`), but SCTP checksum offloads (`skb->csum_not_inet == 1`) require a 4-byte CRC32c. This allows BPF programs to trim SCTP packets such that only the first 2 bytes of the checksum field remain. The hardware will then attempt to process a 4-byte checksum, causing an out-of-bounds access.
--
commit 4cea525b891060e3211b5353724699e42d836d25
Author: Daniel Borkmann <daniel@iogearbox.net>
bpf: Fix bpf_skb_change_tail wrt csum partial skbs
This commit fixes an issue where bpf_skb_change_tail() rejects trims on skbs
carrying a checksum offload, such as those from GRO. It removes the minimum
length restriction from __bpf_skb_min_len() and modifies bpf_skb_trim_rcsum()
to downgrade the checksum to CHECKSUM_NONE if the new length no longer covers
the checksum field.
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 61940e7535523..8513167a858a8 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
[ ... ]
> @@ -3983,6 +3977,11 @@ static int bpf_skb_grow_rcsum(struct sk_buff *skb, unsigned int new_len)
>
> static int bpf_skb_trim_rcsum(struct sk_buff *skb, unsigned int new_len)
> {
> + if (skb->ip_summed == CHECKSUM_PARTIAL &&
> + new_len < skb_checksum_start_offset(skb) + skb->csum_offset +
> + sizeof(__sum16))
> + skb->ip_summed = CHECKSUM_NONE;
> +
[Severity: High]
This is a pre-existing issue, but this patch replicates the flawed 2-byte
assumption from __bpf_skb_min_len(). The checksum field space check in
bpf_skb_trim_rcsum() assumes a 2-byte checksum (sizeof(__sum16)), but SCTP
checksum offloads (skb->csum_not_inet == 1) require a 4-byte CRC32c.
This allows BPF programs to trim SCTP packets such that only the first 2 bytes
of the checksum field remain. If trimmed so that exactly 2 or 3 bytes of the
4-byte CRC32c remain, the length check evaluates to false, and CHECKSUM_PARTIAL
is not cleared. The packet is then handed to the NIC driver.
Passing a truncated CHECKSUM_PARTIAL packet to the NIC hardware causes the
offload engine to access beyond the packet boundary, causing a hardware stall
or OOB write on the wire.
Could we check for skb->csum_not_inet and use a 4-byte length for the checksum
when processing SCTP packets here?
> return __skb_trim_rcsum(skb, new_len);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907121025.1923656-1-daniel@iogearbox.net?part=1
next prev parent reply other threads:[~2026-09-07 12:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 12:10 [PATCH bpf 1/2] bpf: Fix bpf_skb_change_tail wrt csum partial skbs Daniel Borkmann
2026-09-07 12:10 ` [PATCH bpf 2/2] selftests/bpf: Add test for bpf_skb_change_tail on " Daniel Borkmann
2026-09-07 12:24 ` sashiko-bot [this message]
2026-09-07 12:41 ` [PATCH bpf 1/2] bpf: Fix bpf_skb_change_tail wrt " Daniel Borkmann
2026-09-08 2:40 ` patchwork-bot+netdevbpf
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=20260907122414.95F7F1F00ACF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--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;
as well as URLs for NNTP newsgroup(s).