Article View: muc.lists.freebsd.bugs
Article #763[Bug 301146] tcp: handle error path for transient send errors and FIN segments correctly
From: bugzilla-noreply
Date: Thu, 26 Nov 2026 15:51
Date: Thu, 26 Nov 2026 15:51
91 lines
5248 bytes
5248 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301146
Bug ID: 301146
Summary: tcp: handle error path for transient send errors and
FIN segments correctly
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: rscheff@freebsd.org
From commit analysis:
The fix only works when snd_nxt == snd_max at the time of the retransmission.
In SACK retransmissions, the FIN sits at p->rxmit (after p->rxmit += len),
which is snd_una + sbused(&so->so_snd). It has no relation to snd_nxt. Yet the
code still does snd_nxt++ and then derives snd_max from snd_nxt.
Here is a case it misses. After a first RTO, SACK holes are kept
(tcp_resend_sackholes()), snd_nxt is set to snd_una and then moved by
tcp_sack_adjust(). With t_dupacks >= tcprexmtthresh and snd_nxt < snd_max, the
sack_rxmit path runs (tcp_output.c:291). Suppose all data has been sent, the
FIN has not, and the retransmission of the last hole reaches the end of the
send buffer:
- The FIN goes out at sequence snd_max.
- TF_SENTFIN is set.
- snd_nxt++ leaves snd_nxt <= snd_max, so the new SEQ_GT(snd_nxt, snd_max)
check does nothing.
- snd_max still does not include the FIN.
- The "pull snd_nxt along" block then sets snd_nxt = p->end == snd_max.
When the peer ACKs the FIN, th_ack == snd_max + 1, so tcp_input rejects it as
tcps_rcvacktoomuch and drops it after sending an ACK (tcp_input.c:2518, and the
same check in other states). Every later FIN retransmission hits the snd_nxt--
logic at tcp_output.c line 1192, because TF_SENTFIN is set and snd_nxt ==
snd_max. That sends the FIN at snd_max - 1, and snd_max never grows to include
it. The connection stays in FIN_WAIT_1/CLOSING/LAST_ACK until the retransmit
timer gives up.
The snd_nxt++ in the sack_rxmit case is also wrong whenever TF_SENTFIN is
already set and snd_nxt < snd_max: it moves snd_nxt forward one byte for no
reason.
Suggested fix: for sack_rxmit, skip the snd_nxt adjustment for FIN and do "if
(flags & TH_FIN) snd_max = SEQ_MAX(snd_max, p->rxmit + 1)". The error path and
the line-1192 FIN-resend logic would need to match that.
-------------------
pre-existing: a transient send error on a SACK retransmission carrying a FIN
trips the KASSERT "error while FIN with SACK rxmit"
The error path at tcp_output.c:1680 has KASSERT((flags & TH_FIN) == 0, ("error
while FIN with SACK rxmit")). This commit explicitly supports FIN on sack_rxmit
segments, which PR295870 shows already happens. So on an INVARIANTS kernel,
ENOBUFS or any other non-EPERM error from ip_output() on such a segment panics.
On non-INVARIANTS kernels, the error path does not undo the FIN's snd_nxt++,
and now does not undo the snd_max advance either: snd_max covers a FIN that was
never sent. Retransmission should recover from that, but it is inconsistent
with the non-SACK branch, which backs out the FIN.
--
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
Technical Details
Message-ID:
<bug-301146-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 301146] tcp: handle error path for transient send errors and FIN segments correctly Date: Thu, 26 Nov 2026 15:51:18 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-301146-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="57055"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795708278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/T1w1ES1xw1g480UubMhsNsSV/mjaWpXDe+WE6yQPwo=; b=rEcIngqExSEOibHoBxHZ4dS/gCtxoVbkCRzKLTCv4PLs8AB9AmNxWSmeVw4YvVGmmoe3SQ UpuCXprxtHLA322ubd5oAfTMDch0l14dHURK9c2zV819qLQmogqGFvaCDmNkq82qf23nUf o6o4v2QQ/RnRCY81Q9+GixKLbzR4KaApxxj7+1XmmPik5sWgVHqN8cZieh7blk7UQEo0Ge ZSRj8w/eaO7IqEvkQ6TkSg/qJh+QYLOD9mTBgRQTHdeQeccUe2NcC1Xr0V7qalLKxC1FtO AQuIO05FdObsjhuzasaajD1HBAgvGSPGO5XC4AP43vdfdv5RgGNWomVylWdPow== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes