From: netdev-bot+sashiko@kernel.org
To: josef@toxicpanda.com
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch,
jgross@suse.com, sstabellini@kernel.org,
willemdebruijn.kernel@gmail.com, fmancera@suse.de,
almasrymina@google.com, david.laight.linux@gmail.com,
netdev@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH net-next 06/15] net: skbuff: add skb_crc32c_full() that reports failure
Date: Fri, 23 Oct 2026 04:52:04 +0000 [thread overview]
Message-ID: <179273112422.3134.14612188940817308301@kernel.org> (raw)
In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-6-41dbef50b9f7@toxicpanda.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new kernel-doc for skb_crc32c_full() (net/core/skbuff.c,
above line 3810) says it returns -EFAULT when "@skb has unreadable…
- [Low] The commit message says skb_crc32c() 'becomes a wrapper that
behaves as before', but its unreadable-frags WARN now covers less.
--
net: skbuff: add skb_crc32c_full() that reports failure
This commit adds skb_crc32c_full(). When the walk runs into unreadable
frags or past the end of the skb, it returns an error instead of a CRC
of 0. skb_crc32c() becomes a wrapper around it, and
skb_crc32c_csum_help() is converted, so SCTP packets that can't be
checksummed are dropped instead of being sent with a bogus CRC.
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index de433d452939..3b2a3747f009 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3788,23 +3788,41 @@ int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
> EXPORT_SYMBOL(skb_copy_and_csum_bits);
>
> #ifdef CONFIG_NET_CRC32C
> -u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
> +/**
> + * skb_crc32c_full - CRC32C a range of an skb
> + * @skb: buffer to read
> + * @offset: offset in @skb to start at
> + * @len: number of bytes to include
> + * @crcp: the CRC to continue from; on success, updated with the range
> + *
> + * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
> + * has unreadable frags in the range or runs out before @len does. On
> + * failure *@crcp is not changed.
> + */
> +int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)
> {
[ ... ]
> if (copy > 0) {
> copy = min(copy, len);
> crc = crc32c(crc, skb->data + offset, copy);
> len -= copy;
> if (len == 0)
> - return crc;
> + goto out;
> offset += copy;
> }
>
> - if (WARN_ON_ONCE(!skb_frags_readable(skb)))
> - return 0;
> + if (!skb_frags_readable(skb))
> + return -EFAULT;
[Severity: Low]
The kernel-doc above says -EFAULT means "@skb has unreadable frags in
the range". Does this check actually look at the range?
skb_frags_readable() only tests the flag for the whole skb:
include/linux/skbuff.h:skb_frags_readable() {
return !skb->unreadable;
}
Take len == 0 with offset >= skb_headlen(skb). A readable skb walks
zero bytes and returns 0, but an unreadable skb returns -EFAULT here.
Now take a range that lies entirely in readable frag_list children of
an skb whose own frags are unreadable. That also fails here, before the
frag_list loop runs.
No current caller seems to hit this. skb_crc32c_csum_help() always
starts inside the linear head and passes a positive len.
Could the kernel-doc be reworded? Alternatively, this check could apply
only when the remaining range reaches frags[]. skb_checksum_full(),
added earlier in the series, has the same mismatch.
[ ... ]
> @@ -3844,19 +3862,36 @@ u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
> copy = end - offset;
> if (copy > 0) {
> copy = min(copy, len);
> - crc = skb_crc32c(frag_iter, offset - start, copy, crc);
> + err = skb_crc32c_full(frag_iter, offset - start, copy,
> + &crc);
> + if (err)
> + return err;
[ ... ]
> +/* skb_crc32c() has no way to report failure, so it returns 0, which is a
> + * valid CRC. Use skb_crc32c_full() in new code.
> + */
> +u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
> +{
> + if (unlikely(skb_crc32c_full(skb, offset, len, &crc))) {
> + WARN_ON_ONCE(!skb_frags_readable(skb));
[Severity: Low]
The commit message says skb_crc32c() "becomes a wrapper that behaves as
before". Does the unreadable-frags warning still fire for frag_list
children?
Before this patch, the frag_list loop recursed through
skb_crc32c(frag_iter, ...). An unreadable child therefore hit
WARN_ON_ONCE(!skb_frags_readable(skb)) at the child level.
Now the recursion goes through skb_crc32c_full(frag_iter, ...). The
child returns -EFAULT without a warning, and this WARN_ON_ONCE() only
tests the outer skb.
So a readable parent with an unreadable frag_list child now returns 0
to sctp_compute_cksum(), siw_crc_skb() or batadv_bla_check_duplist()
without warning. Before the patch it warned once.
The return value is 0 either way, so only the diagnostic changes.
skb_gro_receive() doesn't seem to check readability when it merges into
frag_list, so this layout looks possible, but that hasn't been confirmed
end to end.
The skb_checksum() wrapper from earlier in the series has the same
pattern.
> + return 0;
> + }
> return crc;
> }
> EXPORT_SYMBOL(skb_crc32c);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7%40toxicpanda.com
next prev parent reply other threads:[~2026-10-23 4:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 13:50 [PATCH net-next 00/15] net: skbuff: follow-ups to the BUG_ON() removal Josef Bacik
2026-10-19 13:50 ` [PATCH net-next 01/15] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags Josef Bacik
2026-10-23 4:51 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 02/15] net: skbuff: add skb_checksum_full() that reports failure Josef Bacik
2026-10-23 4:51 ` netdev-bot+sashiko
2026-10-23 14:01 ` Mina Almasry
2026-10-19 13:50 ` [PATCH net-next 03/15] net: skbuff: fail checksum validation when the skb can't be checksummed Josef Bacik
2026-10-23 4:51 ` netdev-bot+sashiko
2026-10-23 14:12 ` Mina Almasry
2026-10-23 14:37 ` Mina Almasry
2026-10-19 13:50 ` [PATCH net-next 04/15] net: skbuff: fail segmentation when a segment " Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-23 14:14 ` Mina Almasry
2026-10-19 13:50 ` [PATCH net-next 05/15] net: skbuff: fail pskb_trim_rcsum() when it can't checksum the tail Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 06/15] net: skbuff: add skb_crc32c_full() that reports failure Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko [this message]
2026-10-19 13:50 ` [PATCH net-next 07/15] net: skbuff: let skb_zerocopy() copy a short skb without head_frag Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 08/15] net: skbuff: make skb_try_coalesce()'s len unsigned Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 09/15] net: skbuff: check csum_start against len in skb_copy_and_csum_dev() Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 10/15] net: skbuff: reject a negative length in skb_copy_and_csum_bits() Josef Bacik
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 11/15] net: skbuff: refuse to segment a nested frag_list Josef Bacik
2026-10-20 20:09 ` Willem de Bruijn
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 12/15] net: test the frag_list layouts skb_segment() refuses Josef Bacik
2026-10-20 20:17 ` Willem de Bruijn
2026-10-19 13:50 ` [PATCH net-next 13/15] xen-netfront: don't BUG() when skb_copy_bits() fails in bounce_skb() Josef Bacik
2026-10-19 13:50 ` [PATCH net-next 14/15] net/tls: don't BUG() on leftover length in __skb_nsg() Josef Bacik
2026-10-19 15:12 ` Mina Almasry
2026-10-19 16:22 ` Willem de Bruijn
2026-10-19 16:27 ` Mina Almasry
2026-10-23 4:52 ` netdev-bot+sashiko
2026-10-19 13:50 ` [PATCH net-next 15/15] net: update comments that still describe the skb BUG_ON()s Josef Bacik
2026-10-19 15:09 ` Mina Almasry
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=179273112422.3134.14612188940817308301@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=edumazet@kernel.org \
--cc=fmancera@suse.de \
--cc=horms@kernel.org \
--cc=jgross@suse.com \
--cc=josef@toxicpanda.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sstabellini@kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xen-devel@lists.xenproject.org \
/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