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, kaiyuanz@google.com,
almasrymina@google.com, willemb@google.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH net-next 8/9] net: skbuff: don't BUG() on a missing head_frag in skb_zerocopy()
Date: Fri, 09 Oct 2026 08:12:04 +0000 [thread overview]
Message-ID: <179153352480.434549.16663209568702554994@kernel.org> (raw)
In-Reply-To: <20261006-b4-skbuff-bug-on-v1-8-1b4434c5357c@toxicpanda.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] skb_zerocopy() now WARNs and returns -EFAULT on a legitimate,
user-reachable input: an empty (len == 0) skb without head_frag.
- [Low] The kernel-doc 'Return value' section of skb_zerocopy() lists
exactly two causes of -EFAULT: 'skb_copy_bits() found some problem…
- [Low] The patch removes a BUG() in skb_zerocopy() that userspace can
actually reach, but the commit message has no Fixes: tag (the first…
--
net: skbuff: don't BUG() on a missing head_frag in skb_zerocopy()
This commit replaces the BUG_ON(!from->head_frag && !hlen) check in
skb_zerocopy() with a WARN_ON_ONCE() that returns -EFAULT. The commit
message describes the condition as a caller bug. It also says -EFAULT is
already documented for bad skb geometry.
> skb_zerocopy() BUG()s if @from has no head_frag and the caller passed
> hlen == 0, meaning the caller didn't ask for the head to be copied and
> the head can't be referenced as a page either. The check runs before
> anything is touched, and skb_zerocopy() already documents -EFAULT for
> bad skb geometry. Warn once and return that.
[Severity: Low]
Should this carry a Fixes: tag?
Userspace can reach the BUG() removed here through openvswitch.
OVS_PACKET_CMD_EXECUTE only needs GENL_UNS_ADMIN_PERM. A 14-byte Ethernet
frame with the actions POP_ETH and then USERSPACE ends up here:
ovs_packet_cmd_execute()
__dev_alloc_skb(NET_IP_ALIGN + len, GFP_KERNEL) /* head_frag == 0 */
...
do_execute_actions()
pop_eth() /* skb->len goes from 14 to 0 */
output_userspace()
ovs_dp_upcall()
queue_userspace_packet()
skb_zerocopy(user_skb, skb, 0, 0)
BUG_ON(!from->head_frag && !hlen)
There are two likely candidates for the tag. One is the commit that added
the BUG_ON() to skb_zerocopy(). The other is the commit that made POP_ETH
followed by USERSPACE produce empty upcalls.
The first patch in this series, "net: skbuff: don't leave stale bytes in
skb_copy_and_csum_bits()", has a Fixes: tag.
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index e29eda2eaf3f6..8c6a45a20eb0f 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3906,7 +3906,8 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
> struct page *page;
> unsigned int offset;
>
> - BUG_ON(!from->head_frag && !hlen);
> + if (WARN_ON_ONCE(!from->head_frag && !hlen))
> + return -EFAULT;
[Severity: Medium]
Can this WARN fire on a valid empty copy?
When len == 0 there is nothing to copy, so hlen == 0 is not a caller bug
in that case. The kernel-doc names skb_zerocopy_headlen() as the source
of @hlen, and it returns 0 for an empty skb without head_frag:
net/core/skbuff.c:skb_zerocopy_headlen() {
...
if (!from->head_frag || ...) {
hlen = skb_headlen(from);
if (!hlen)
hlen = from->len;
}
...
}
The openvswitch path above hits this case. queue_userspace_packet()
computes skb_len = min(skb->len, cutlen), which is 0. hlen is also 0 on
both the OVS_DP_F_UNALIGNED path and the aligned path. The skb was
allocated with GFP_KERNEL, so head_frag is 0.
If the check came after the small payload fast path, this call would
simply return 0:
if (len <= skb_tailroom(to))
return skb_copy_bits(from, 0, skb_put(to, len), len);
Because the check comes first, userspace can trigger a WARN splat (or a
panic with panic_on_warn), and the empty upcall fails with -EFAULT.
Would adding len && to the condition, or moving the check below the fast
path, avoid this?
[Severity: Low]
Should the skb_zerocopy() kernel-doc be updated as well? Its return value
section lists only two causes of -EFAULT:
* -EFAULT: skb_copy_bits() found some problem with skb geometry, or readable head
* payload would be mixed with unreadable frags.
The new return happens before skb_copy_bits() is called and has nothing
to do with unreadable frags. The @hlen description ("size of linear
headroom in destination buffer") also doesn't say that hlen must be
non-zero when @from has no head_frag.
The commit message says skb_zerocopy() "already documents -EFAULT for
bad skb geometry". The doc only uses that wording for skb_copy_bits()
failures.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006-b4-skbuff-bug-on-v1-0-1b4434c5357c%40toxicpanda.com
next prev parent reply other threads:[~2026-10-09 8:12 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
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 [this message]
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=179153352480.434549.16663209568702554994@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=almasrymina@google.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kaiyuanz@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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