Thread View: muc.lists.freebsd.bugs
1 messages
1 total messages
Started by bugzilla-noreply
Thu, 26 Nov 2026 15:51
[Bug 301146] tcp: handle error path for transient send errors and FIN segments correctly
Author: 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
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