Hello,
Jakub applied v2 of my skbuff BUG_ON() series[1] before I got v3 out, so
this is what v3 would have changed, as fixes on top of what landed, plus
the skb_copy_and_csum_bits() patch I'd been sending to net on its own.
Patch 1 is that patch[2], moved to net-next as Mina suggested, with his
Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the
rest of the series builds on it. Please drop the net version.
Patches 2 through 6 deal with skb_checksum() and skb_crc32c(). My v2
had them return 0 when they run out of skb, and that turned out not to
be safe: 0 is a valid checksum, and it can make a packet that was never
fully checksummed pass verification. So they get versions that report
failure, skb_checksum_full() and skb_crc32c_full(), and the core users
switch to them: checksum validation now rejects a packet it can't
checksum, skb_segment() and pskb_trim_rcsum() fail instead of using a
bad sum, and skb_crc32c_csum_help() drops the packet. skb_checksum()
and skb_crc32c() stay as wrappers that behave as before, and I'll
convert the rest of their callers per subsystem in later series.
Patches 7 through 10 fix problems Sashiko and an LLM review found in
what was applied. skb_zerocopy() refuses a zero-length copy that Open
vSwitch can trigger from a user namespace, skb_try_coalesce() and
skb_copy_and_csum_bits() can be handed a negative length, and
skb_headlen() can underflow in skb_copy_and_csum_dev().
Patches 11 and 12 make skb_segment() refuse a nested frag_list, which
could still oops on a NULL list_skb, and add KUnit cases for the layouts
it refuses. Patches 13 and 14 get rid of the same BUG_ON()s in
xen-netfront's bounce_skb() and tls's __skb_nsg(), and patch 15 updates
comments that still describe the old BUG_ON()s.
I tested this with the net_core KUnit tests, a test module that drives
each of these paths under KASAN and fault injection, an Open vSwitch
reproducer for patch 7, and a stress run over veth with netem. Thanks,
Josef
[1] https://lore.kernel.org/all/20261007-b4-skbuff-bug-on-v2-0-b9a5f732895b@toxicpanda.com/
[2] https://lore.kernel.org/all/20261013-b4-skb-segment-nosg-unreadable-v2-1-6c28d8ffa51e@toxicpanda.com/
---
Josef Bacik (15):
net: skbuff: make skb_copy_and_csum_bits() report unreadable frags
net: skbuff: add skb_checksum_full() that reports failure
net: skbuff: fail checksum validation when the skb can't be checksummed
net: skbuff: fail segmentation when a segment can't be checksummed
net: skbuff: fail pskb_trim_rcsum() when it can't checksum the tail
net: skbuff: add skb_crc32c_full() that reports failure
net: skbuff: let skb_zerocopy() copy a short skb without head_frag
net: skbuff: make skb_try_coalesce()'s len unsigned
net: skbuff: check csum_start against len in skb_copy_and_csum_dev()
net: skbuff: reject a negative length in skb_copy_and_csum_bits()
net: skbuff: refuse to segment a nested frag_list
net: test the frag_list layouts skb_segment() refuses
xen-netfront: don't BUG() when skb_copy_bits() fails in bounce_skb()
net/tls: don't BUG() on leftover length in __skb_nsg()
net: update comments that still describe the skb BUG_ON()s
drivers/net/ethernet/sun/sunvnet_common.c | 10 +-
drivers/net/xen-netfront.c | 7 +-
include/linux/skbuff.h | 8 +-
net/core/dev.c | 7 +-
net/core/filter.c | 6 +-
net/core/net_test.c | 52 +++++-
net/core/skbuff.c | 274 +++++++++++++++++++++++-------
net/ipv4/icmp.c | 9 +-
net/ipv4/ip_output.c | 11 +-
net/ipv6/icmp.c | 7 +-
net/ipv6/ip6_output.c | 11 +-
net/sunrpc/socklib.c | 9 +-
net/tls/tls_sw.c | 5 +-
13 files changed, 327 insertions(+), 89 deletions(-)
---
base-commit: 6b3e73774815910a39d8ca75b9ad7df963f61d50
change-id: 20261016-b4-skbuff-bug-on-followups-ad11adf285a4