git: 427a78da3629 - stable/14 - tcp: count only the SACK blocks that fit in tcp_maxseg()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 19:59:44 UTC
The branch stable/14 has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=427a78da3629d436ae11c9bdc0c9d5a0c5371d0a
commit 427a78da3629d436ae11c9bdc0c9d5a0c5371d0a
Author: Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-11-13 20:27:46 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-26 18:58:17 +0000
tcp: count only the SACK blocks that fit in tcp_maxseg()
tcp_addoptions() sends only the SACK blocks that fit in TCP_MAXOLEN.
tcp_maxseg() counted every pending block and clamped the total, so
without timestamps and with five or more blocks pending it came out 4
bytes below the segment tcp_output() sends. Limited transmit after an
RTO then sent one full segment and failed the "sent too much" KASSERT.
PR: 282605
Approved by: adrian (mentor)
Signed-off-by: Nick Price <nprice@FreeBSD.org>
Reviewed by: tuexen, glebius, adrian
Differential Revision: https://reviews.freebsd.org/D60460
(cherry picked from commit d3b02115d4b373c719d9a716da38d94511de3f07)
---
sys/netinet/tcp_subr.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 3df756f23d49..aa8533f2a3c7 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -3587,9 +3587,12 @@ tcp_maxseg(const struct tcpcb *tp)
optlen += PADTCPOLEN(TCPOLEN_SIGNATURE);
#endif
if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) {
- optlen += TCPOLEN_SACKHDR;
- optlen += tp->rcv_numsacks * TCPOLEN_SACK;
- optlen = PADTCPOLEN(optlen);
+ u_int sackblks;
+
+ sackblks = min(tp->rcv_numsacks, (TCP_MAXOLEN - optlen -
+ PADTCPOLEN(TCPOLEN_SACKHDR)) / TCPOLEN_SACK);
+ optlen += PADTCPOLEN(TCPOLEN_SACKHDR +
+ sackblks * TCPOLEN_SACK);
}
} else {
if (tp->t_flags & TF_REQ_TSTMP)