linux/net
Xinyang Ge 29dda278a5 inet: frags: strip GSO state from fragments before reassembly
commit d5dc1e69fd upstream.

A virtio_net_hdr (tun/tap, or AF_PACKET with PACKET_VNET_HDR) can mark
an IPv4 or IPv6 fragment as GSO; nothing relates gso_type to frag_off.
inet_frag_reasm_prepare()/inet_frag_reasm_finish() keep the first
fragment's skb as the head of the reassembled datagram, including its
shinfo->gso_size/gso_type/gso_segs, and chain the remaining fragments
on frag_list with whatever linear/paged layout they arrived with.

After ip_defrag() (ip_local_deliver(), nf_defrag_ipv4, ...) the
reassembled skb therefore still claims to be GSO (SKB_GSO_DODGY), and
the next software segmentation point - udp_rcv_segment() on local
delivery, validate_xmit_skb(), or the ip_finish_output_gso() slow
path - hands it to skb_segment(). skb_segment()'s frag_list walk
assumes GRO-shaped input and hits one of its BUG_ON()s. Two writes to
a tap by an unprivileged user in its own userns are enough:

  kernel BUG at net/core/skbuff.c:4899!
  Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
  CPU: 0 UID: 1000 PID: 82 Comm: poc Not tainted 7.2.0-pentest+ #2
  RIP: 0010:skb_segment+0x20ca/0x48b0
  Call Trace:
   <TASK>
   __udp_gso_segment+0x29a/0x27d0
   udp4_ufo_fragment+0x458/0x6c0
   inet_gso_segment+0x429/0x1340
   skb_mac_gso_segment+0x233/0x4f0
   __skb_gso_segment+0x308/0x660
   udp_queue_rcv_skb+0x440/0xad0
   udp_unicast_rcv_skb+0xc7/0x2c0
   udp_rcv+0x16ce/0x2260
   ip_protocol_deliver_rcu+0x197/0x2d0
   ip_local_deliver+0x430/0x690
   ip_rcv+0x16f/0x1f0
   __netif_receive_skb_one_core+0x15e/0x1c0
   __netif_receive_skb+0x1e/0x110
   netif_receive_skb+0xf6/0x5c0
   tun_rx_batched.isra.0+0x3ab/0x790
   tun_get_user+0x17c3/0x3550
   tun_chr_write_iter+0xba/0x1b0
   vfs_write+0x646/0x1130
   </TASK>
  Kernel panic - not syncing: Fatal exception in interrupt

This runs with BH disabled, so it is a panic rather than an oops. The
same is reachable with CAP_NET_RAW in a netns where a defrag point
precedes a GSO point, and from a guest whose VMM forwards
virtio_net_hdr to a tap. The SKB_GSO_DODGY frag_list checks added by
commit 3dcbdb134f ("net: gso: Fix skb_segment splat when splitting
gso_size mangled skb having linear-headed frag_list") and by
commit 9e4b7a99a0 ("net: gso: fix panic on frag_list with mixed head
alloc types") do not cover it: page-backed heads skip them, and kmalloc
heads skip them when gso_size == skb_headlen(head), which the sender
controls.

An skb entering a frag queue is an IP fragment by definition and
cannot legitimately carry GSO state: GRO does not merge fragments and
the stack segments before it fragments, so only untrusted sources are
affected. This has been reachable since
commit f43798c276 ("tun: Allow GSO using virtio_net_hdr"), the first
path that let userspace attach GSO metadata to an IP fragment. Reset
the GSO fields of every fragment as it is queued, in
inet_frag_queue_insert(), which IPv4, IPv6, nf_conntrack_reasm and
6lowpan reassembly share; then neither the head nor the frag_list
members of the reassembled skb carry them (the members matter too:
the ip_do_fragment()/ip6_fragment() fast paths send them out as they
are). The head may remain CHECKSUM_PARTIAL; that is already accepted
on receive and resolved by skb_checksum_help() in
ip_do_fragment()/ip6_fragment() on forward.

Tested on top of net.git (dc4b95b8fe), x86_64: the tap reproducer
above, two further IPv4 frag_list geometries that reach
BUG_ON(i >= nfrags) and BUG_ON(!list_skb->head_frag), and an IPv6
fragment-header variant (udp6_ufo_fragment()) each panic the unpatched
kernel; with this patch all four datagrams are delivered intact and
nothing is logged.

Fixes: f43798c276 ("tun: Allow GSO using virtio_net_hdr")
Cc: stable@kernel.org
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Xinyang Ge <xinyang@anthropic.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/937926e509f2acd8e0e66520dc2b30fd6b4d1687.1787839506.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-08-28 08:20:31 +02:00
..
6lowpan 6lowpan: fix NHC entry use-after-free on error path 2026-07-24 15:51:20 +02:00
9p net/9p: fix infinite loop in p9_client_rpc on fatal signal 2026-07-24 15:51:50 +02:00
802 net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr 2026-06-19 13:33:34 +02:00
8021q net: vlan: sync VLAN features with lower device 2025-12-07 06:09:26 +09:00
appletalk net: appletalk: Fix use-after-free in AARP proxy probe 2025-08-28 16:24:04 +02:00
atm net: atm: reject out-of-range traffic classes in QoS validation 2026-07-24 15:51:46 +02:00
ax25 ax25: properly unshare skbs in ax25_kiss_rcv() 2025-09-09 18:50:20 +02:00
batman-adv batman-adv: clean untagged VLAN on netdev registration failure 2026-07-24 15:51:53 +02:00
bluetooth Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept 2026-08-27 14:28:18 +02:00
bpf bpf: reject short IPv4/IPv6 inputs in bpf_prog_test_run_skb 2026-06-01 17:35:29 +02:00
bpfilter bpfilter: Specify the log level for the kmsg message 2021-06-25 13:13:50 +02:00
bridge netfilter: bridge: release template ct on non-IP path 2026-08-19 17:14:17 +02:00
caif net: caif: clear client service pointer on teardown 2026-06-01 17:35:14 +02:00
can can: isotp: fix timer drain order, wakeup handling and tx_gen ordering 2026-08-27 14:28:22 +02:00
ceph libceph: fix OOB read in decode_watchers() via missing bounds check 2026-08-27 14:28:20 +02:00
core net: pktgen: fix proc entry use-after-free 2026-08-23 14:17:29 +02:00
dcb net: dcb: choose correct policy to parse DCB_ATTR_BCN 2023-08-11 15:13:53 +02:00
dccp net: fix data-races around sk->sk_forward_alloc 2025-01-23 17:16:04 +01:00
dns_resolver keys, dns: Fix size check of V1 server-list header 2024-01-25 14:52:46 -08:00
dsa net: dsa: tag_ksz: do not rely on skb_mac_header() in TX paths 2026-07-24 15:51:27 +02:00
ethernet gro: remove rcu_read_lock/rcu_read_unlock from gro_complete handlers 2024-09-12 11:07:47 +02:00
ethtool ethtool: eeprom: add more safeties to EEPROM Netlink fallback 2026-06-19 13:33:24 +02:00
hsr net: hsr: fix memory leak on slave unregistration by removing synced VLANs 2026-08-19 17:13:58 +02:00
ieee802154 ieee802154: allow legacy LLSEC ADD/DEL ops to pass strict validation 2026-07-24 15:51:53 +02:00
ife net: ife: require ETH_HLEN to be pullable in ife_decode() 2026-07-24 15:51:46 +02:00
ipv4 inet: frags: strip GSO state from fragments before reassembly 2026-08-28 08:20:31 +02:00
ipv6 ipv6: fix use-after-free in ip6_finish_output2() 2026-08-27 14:28:21 +02:00
iucv net/iucv: fix use-after-free of a severed iucv_path 2026-08-19 17:14:04 +02:00
kcm kcm: use WRITE_ONCE() when changing lower socket callbacks 2026-07-24 15:51:36 +02:00
key net: af_key: initialize alg_key_len for IPComp states 2026-07-24 15:51:21 +02:00
l2tp l2tp: Drop large packets with UDP encap 2026-06-01 17:35:03 +02:00
l3mdev net: Add l3mdev index to flow struct and avoid oif reset for port devices 2024-10-17 15:11:57 +02:00
lapb net: lapb: Use list_for_each_entry() to simplify code in lapb_iface.c 2021-06-08 16:31:25 -07:00
llc llc: fix SAP refcount leak when creating incoming sockets 2026-07-24 15:51:55 +02:00
mac80211 wifi: mac80211: validate individual TWT params before driver setup 2026-08-19 17:14:07 +02:00
mac802154 mac802154: llsec: reject frames shorter than the authentication tag 2026-08-19 17:14:04 +02:00
mctp net: mctp: fix don't require received header reserved bits to be zero 2026-06-19 13:33:41 +02:00
mpls net: mpls: initialize rtm_tos in mpls_getroute() 2026-08-19 17:14:05 +02:00
mptcp mptcp: pm: fix data race in add_addr timer callback 2026-08-27 14:28:22 +02:00
ncsi net/ncsi: fix heap OOB read in NCSI_CMD_SEND_CMD payload length 2026-08-19 17:14:14 +02:00
netfilter netfilter: ipset: fix list type element drift bug 2026-08-23 14:17:31 +02:00
netlabel netlabel: validate unlabeled address and mask attribute lengths 2026-06-19 13:33:35 +02:00
netlink rtnetlink: add RTNL_FLAG_DUMP_UNLOCKED flag 2026-07-24 15:51:42 +02:00
netrom netrom: fix double-free in nr_route_frame() 2026-02-06 16:41:58 +01:00
nfc nfc: nci: free destination parameters when closing a connection 2026-08-27 14:28:20 +02:00
nsh nsh: Restore skb->{protocol,data,mac_header} for outer header in nsh_gso_segment(). 2024-05-17 11:50:48 +02:00
openvswitch openvswitch: move key and ovs_cb update out of handle_fragments 2026-08-23 14:17:30 +02:00
packet packet: synchronize pressure clearing with ring reconfiguration 2026-08-27 14:28:20 +02:00
phonet phonet: pep: fix use-after-free in pep_get_sb() 2026-08-19 17:14:03 +02:00
psample net: psample: fix info leak in PSAMPLE_ATTR_DATA 2026-07-24 15:51:39 +02:00
qrtr net: qrtr: ns: Raise lookup limit to 128 2026-08-19 17:14:14 +02:00
rds rds: tcp: hold the RCU lock across ipv6_chk_addr() in rds_tcp_laddr_check() 2026-08-19 17:14:06 +02:00
rfkill net: rfkill: prevent unlimited numbers of rfkill events from being created 2026-04-18 10:33:38 +02:00
rose net/rose: fix NULL pointer dereference in rose_transmit_link on reconnect 2026-04-18 10:33:20 +02:00
rxrpc rxrpc: serialize kernel accept preallocation with socket teardown 2026-08-23 14:17:18 +02:00
sched net/sched: reject overly deep qdisc hierarchies 2026-08-27 14:28:19 +02:00
sctp sctp: avoid auth_enable sysctl UAF during netns teardown 2026-08-23 14:17:27 +02:00
smc net: smc: fix splice entry lifetime imbalance in smc_rx_splice 2026-08-23 14:17:30 +02:00
strparser net: strparser: fix skb_head leak in strp_abort_strp() 2026-06-01 17:35:14 +02:00
sunrpc xprtrdma: Fix bcall rep leak and unbounded peek 2026-07-24 15:51:38 +02:00
switchdev net: make switchdev_bridge_port_{,unoffload} loosely coupled with the bridge 2021-08-04 12:35:07 +01:00
tipc tipc: restrict socket queue dumps in enqueue tracepoints 2026-08-23 14:17:18 +02:00
tls tls: don't abort the connection on signal-interrupted sends 2026-08-19 17:14:14 +02:00
unix af_unix: Reject SIOCATMARK on non-stream sockets 2026-07-04 13:39:37 +02:00
vmw_vsock vsock/virtio: avoid refilling the RX queue after teardown 2026-08-19 17:14:17 +02:00
wireless wifi: cfg80211: bound element ID read when checking non-inheritance 2026-08-19 17:13:53 +02:00
x25 net/x25: fix use-after-free of the socket by its timers 2026-08-23 14:17:31 +02:00
xdp xsk: tighten UMEM headroom validation to account for tailroom and min frame 2026-06-01 17:35:02 +02:00
xfrm xfrm: fix sk_dst_cache double-free in xfrm_user_policy() 2026-08-27 14:28:22 +02:00
compat.c use less confusing names for iov_iter direction initializers 2026-06-19 13:33:46 +02:00
devres.c net: devres: Correct a grammatical error 2021-06-11 12:55:28 -07:00
Kconfig Remove DECnet support from kernel 2023-06-21 15:59:15 +02:00
Makefile Remove DECnet support from kernel 2023-06-21 15:59:15 +02:00
socket.c net: Drop the lock in skb_may_tx_timestamp() 2026-07-24 15:51:21 +02:00
sysctl_net.c net: Ensure net namespace isolation of sysctls 2021-04-12 13:27:11 -07:00