Thread View: muc.lists.freebsd.bugs
3 messages
3 total messages
Started by bugzilla-noreply
Wed, 02 Dec 2026 01:31
[Bug 301389] ip6_output() leaks stale CSUM_TSO onto IPv6 fragments after TSO6 disable / route change (causes iflib MPASS panic a...
Author: bugzilla-noreply
Date: Wed, 02 Dec 2026 01:31
Date: Wed, 02 Dec 2026 01:31
189 lines
9688 bytes
9688 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301389
Bug ID: 301389
Summary: ip6_output() leaks stale CSUM_TSO onto IPv6 fragments
after TSO6 disable / route change (causes iflib MPASS
panic and NIC TX wedges)
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: william.a@carrel.org
Created attachment 278057
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=278057&action=edit
[patch] correct TSO6 handling in ip6_output.c
Note: Gemini 4 Neon assisted with the investigation, codebase audit, and patch
preparation for this report.
Summary
=======
ip6_output() in sys/netinet6/ip6_output.c has two related TSO6 handling bugs
when an IPv6 TCP packet carries CSUM_TSO:
1. Wrong TSO6 capability mask:
tcp_output() sets m->m_pkthdr.csum_flags |= CSUM_TSO (CSUM_IP_TSO |
CSUM_IP6_TSO). ip6_output() checks:
(sw_csum & ifp->if_hwassist & (CSUM_TSO | CSUM_INNER_TSO)) != 0
rather than (CSUM_IP6_TSO | CSUM_INNER_TSO). On an interface where TSO4 is
enabled (CSUM_IP_TSO set in if_hwassist) and TSO6 is disabled (-tso6), this
evaluates tso = 1 and passes unsegmented IPv6 TSO frames to a driver with TSO6
disabled.
2. Missing EMSGSIZE rejection when tso == 0:
When an established TCPv6 socket already has TF_TSO cached in tp->t_flags
and the egress interface subsequently loses TSO6 (for example, if_bridge
attaching a non-TSO epair/tap member via bridge_capabilities(), ifconfig <if>
-tso6, or route failover to a non-TSO6 interface), ip6_output() sets tso = 0
(dontfrag = 0) and leaves CSUM_TSO and tso_segsz in m->m_pkthdr.
- Unlike IPv4 ip_output() (which sees CSUM_TSO when tlen > mtu and returns
EMSGSIZE so tcp_output() clears TF_TSO and re-segments via goto again),
ip6_output() only calls ip6_output_delayed_csum() (clearing
CSUM_DELAY_DATA_IPV6, not CSUM_IP6_TSO) and falls through to ip6_fragment().
- ip6_fragment() calls m_dup_pkthdr(), copying the stale CSUM_TSO flag and
tso_segsz onto every IPPROTO_FRAGMENT mbuf.
Impact
======
FreeBSD NIC drivers rely on the IP output path to validate offloads against
if_hwassist:
- iflib (em, igb, ix, ixl, ice, igc, bnxt, vmx, axgbe, mgb, etc.):
iflib_encap() copies m->m_pkthdr.csum_flags into pi.ipi_csum_flags without
masking by if_hwassist. In iflib_parse_header() (sys/net/iflib.c),
pi->ipi_ipproto is IPPROTO_FRAGMENT, so the IPPROTO_TCP header-parsing block is
skipped (leaving ipi_tcp_hlen = 0), yet execution still enters if
(IS_TSO6(pi)):
* On INVARIANTS kernels: MPASS(ip6->ip6_nxt == IPPROTO_TCP)
(sys/net/iflib.c:3720) immediately panics the kernel.
* On RELEASE kernels: th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0)
(sys/net/iflib.c:3725) writes into unused trailing mbuf data space past
m->m_len, and passes CSUM_IP6_TSO | CSUM_IP6_TCP with ipi_tcp_hlen == 0 to
hardware, producing malformed TSO6 descriptors.
- Other drivers (re(4), realtek-re-kmod, cxgbe(4), ena(4), gve(4)):
Do not mask csum_flags against if_hwassist and program hardware TSO
descriptors for IPPROTO_FRAGMENT packets. On Realtek RTL8168H
(realtek-re-kmod), this consistently wedges the TX ring and triggers "re0: TX
watchdog: stalled". It recovers, but is disruptive.
How to Reproduce
================
1. Establish an active bulk TCPv6 transfer over a TSO6-capable egress interface
(e.g., bridged interface or direct NIC) so TF_TSO is cached on the socket.
2. Disable TSO6 while the connection is active -- for example by attaching an
epair interface (for a VNET jail) or tap interface to an if_bridge containing
the egress NIC (which strips IFCAP_TSO4 | IFCAP_TSO6), or by running "ifconfig
<if> -tso6", or via route failover to a non-TSO6 interface.
3. Observe ip6_fragment() emitting IPPROTO_FRAGMENT packets with stale CSUM_TSO
/ tso_segsz != 0, triggering an iflib_parse_header() MPASS panic on INVARIANTS
kernels or TX watchdog stalls / malformed TSO descriptors on hardware.
Proposed Fix
============
In sys/netinet6/ip6_output.c:
1. Check CSUM_IP6_TSO | CSUM_INNER_TSO instead of CSUM_TSO | CSUM_INNER_TSO.
2. Return EMSGSIZE before ip6_output_delayed_csum() whenever !tso and
(m->m_pkthdr.csum_flags & (CSUM_TSO | CSUM_INNER_TSO)) != 0, avoiding wasted
software checksum work, avoiding sending MSS-violating unsegmented packets when
tlen <= mtu, and letting tcp_output() clear TF_TSO and re-segment cleanly.
3. Clear CSUM_TSO | CSUM_INNER_TSO and tso_segsz in ip6_fragment() after
m_dup_pkthdr() as defense in depth.
Patch (against main):
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 0c259e9df0..dbcb47cd28 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -262,6 +262,8 @@ ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int hlen,
u_char nextproto,
IP6STAT_INC(ip6s_odropped);
return (ENOBUFS);
}
+ m->m_pkthdr.csum_flags &= ~(CSUM_TSO | CSUM_INNER_TSO);
+ m->m_pkthdr.tso_segsz = 0;
*mnext = m;
mnext = &m->m_nextpkt;
@@ -1120,10 +1122,24 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
sw_csum = m->m_pkthdr.csum_flags;
if (!hdrsplit) {
tso = ((sw_csum & ifp->if_hwassist &
- (CSUM_TSO | CSUM_INNER_TSO)) != 0) ? 1 : 0;
+ (CSUM_IP6_TSO | CSUM_INNER_TSO)) != 0) ? 1 : 0;
sw_csum &= ~ifp->if_hwassist;
} else
tso = 0;
+
+ /*
+ * If TSO was requested (e.g., TF_TSO was cached before the interface
+ * lost TSO6 capability or the route changed) but cannot be performed,
+ * return EMSGSIZE so tcp_output() clears TF_TSO and re-segments
+ * instead of sending unsegmented packets or fragments with stale
+ * CSUM_TSO.
+ */
+ if (!tso &&
+ (m->m_pkthdr.csum_flags & (CSUM_TSO | CSUM_INNER_TSO)) != 0) {
+ in6_ifstat_inc(ifp, ifs6_out_fragfail);
+ error = EMSGSIZE;
+ goto bad;
+ }
/*
* If we added extension headers, we will not do TSO and calculate the
* checksums ourselves for now.
Additional Defense-in-Depth Note
================================
iflib_parse_header() / iflib_encap() in sys/net/iflib.c would also benefit from
guarding IS_TSO6(pi) on pi->ipi_ipproto == IPPROTO_TCP and/or masking
pi.ipi_csum_flags against if_gethwassist(ifp).
Testing Status
==============
- The stale CSUM_TSO / ip6_fragment() failure was observed and isolated on
FreeBSD 15.1-RELEASE-p7 (amd64) with if_bridge, epair VNET jails, and an
RTL8168H controller (realtek-re-kmod), where gating TX offload handling on
if_hwassist in the driver eliminated the "TX watchdog: stalled" failures.
- The ip6_output.c patch against main above has been verified on amd64 with
if_re on 15.1-RELEASE-p7.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301389] ip6_output() leaks stale CSUM_TSO onto IPv6 fragments after TSO6 disable / route change (causes iflib MPASS panic a...
Author: bugzilla-noreply
Date: Wed, 02 Dec 2026 01:31
Date: Wed, 02 Dec 2026 01:31
17 lines
2587 bytes
2587 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301389
William Carrel <william.a@carrel.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #278057|0 |1
is patch| |
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301389] ip6_output() leaks stale CSUM_TSO onto IPv6 fragments after TSO6 disable / route change (causes iflib MPASS panic a...
Author: bugzilla-noreply
Date: Wed, 02 Dec 2026 01:35
Date: Wed, 02 Dec 2026 01:35
16 lines
2612 bytes
2612 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301389
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |net@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads