From nobody Thu Aug 6 08:33:31 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hG0t91WRjz6mcyC for ; Thu, 06 Aug 2026 08:33:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hG0t900Zyz3R0h for ; Thu, 06 Aug 2026 08:33:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786005217; 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=g06QhSE58fBjYoMkurK9PSEJEL8z4u3Q8YIYS6SwjvM=; b=eg42eLSdN8vg3R5io1FU+7hdjkXpJIS3NTdEedYAgnSoqzoxTpqDzcEAbGuui+y4EFMVCt VSjLIfDvQ3QIS8UjK6YXLUn3Nv7ooVygrsadvJALLcFgFDHgfSW1BI/Kr4gTsYI+PMQR+j 2dpmj3g0YIJzv83k/iPkWyHyI6FKKQW+f/H54WaZGYgLZMERGUE5vxH2AKlsl6YSuGXk1P LgagzW+8F0Y+miAnQviRpIJDNUatosKm/kDUl1mQcQk2d/65/65IsR+ngoumhxdG11BRWC cuZatmNB5Dan8M/e54NX1DGBB/gx5rKWc8m3AQ62WbxcpMlZLQ3XwaMoEffoIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786005217; a=rsa-sha256; cv=none; b=UZhgFkGcAUUHG00RUmduIlhrXHqYsOVXRkQoQhtvSmXRZ+gx99BD/EKhVeQe5SXCivRd6S FO3a0a5YaYuHWrrUkLsghGpNuJxGwzPD4B51nKZ+oVsRyZA7QsqKyBi2Hcu//ibV4qmZWi KZMflV4YZyWWrmbmFedDJdsN5kgl2UMcCXwoBZUbtHhcTiRcQrHEpGU+MyNt2qmOw5U9X0 J/7hYJTgrH+MEnV7abS52VRYberBBntZjEgpzCs7gmETbhtDDyv4Nm/Szjez9xR0NnaQLx xvuVtWChxXTPYHAaA8W2UCGSXcccpiD8/7I6b4tiaWu1FQOg62I+xv7TIXDqiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786005217; 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=g06QhSE58fBjYoMkurK9PSEJEL8z4u3Q8YIYS6SwjvM=; b=XMypYfHJXKhnf/CvPEi9L12p1rWxnr1c+8Ku9r4xrNVVA3mtMFMTibP7+iolVPR0YWfzbJ FnQ/lJmI7Nzyma/IkPldEFzqHSL1ElM3QtHCDj/RjofJxxYeLmGtlILyqeEDfWIKyACJ2q jd5OJFyf19tT4JJlZKMYYhaaB2oIsAwwnm65LLBhl0tv1Wr1wrzWvzlQEUV/OJaNjpcvBe eqsv+WgBMB5ECln8bP2f6i4sRdpPdZ7CRaEHqFvdjQyX1WjJR8nAYPhyTxwrJ925QSdZ1n tpv1xuN3lHVq2flCmQpt1gDS5G4CAIHO9ZVcc+D3wHAKcgu9wycNiySaYnRmqw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hG0t86BV6z1C1Y for ; Thu, 06 Aug 2026 08:33:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3c7d4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 06 Aug 2026 08:33:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 1c62c8bac5ae - stable/14 - tcp: improve SEG.SEQ validation for RST segments List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1c62c8bac5ae5ede9b65d32b08e10ae05aa955ac Auto-Submitted: auto-generated Date: Thu, 06 Aug 2026 08:33:31 +0000 Message-Id: <6a7446db.3c7d4.3eca70b@gitrepo.freebsd.org> The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=1c62c8bac5ae5ede9b65d32b08e10ae05aa955ac commit 1c62c8bac5ae5ede9b65d32b08e10ae05aa955ac Author: Michael Tuexen AuthorDate: 2026-08-03 11:07:32 +0000 Commit: Michael Tuexen CommitDate: 2026-08-06 05:56:07 +0000 tcp: improve SEG.SEQ validation for RST segments A RST segment can be sent in response to (a) received segment or (b) by the upper layer protocol. The SEG.SEQ validation consists of two checks: (1) the in-window check of SEG.SEQ and (2) the exact match check of SEG.SEQ. For the in-window check (1), the left edge of the window needs to be based on tp->last_ack_sent to cover the delayed ACK case, whereas the right edge needs to be based on tp->rcv_nxt + tp->rcv_wnd. This both assumes that tp->rcv_wnd is not zero. For the special case of tp->rcv_wnd being zero, add checks against tp->last_ack_sent for (a) and on tp->rcv_nxt for (b). This applies to all TCP stacks. When the exact match (2) of SEG.SEQ is performed, it should be based on tp->last_ack_sent for (a) and on tp->rcv_nxt for (b). To cover both, check for both. Add this only to the base stack, since the RACK and BBR stacks already do this. PR: 296594 Reviewed by: rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D58594 (cherry picked from commit c9df1a6cf9be9d44eacc8616ebba1cd19010c7fc) --- sys/netinet/tcp_input.c | 18 ++++++++++++------ sys/netinet/tcp_stacks/rack_bbr_common.c | 22 ++++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 9dfd38d679e9..5ff4597abe6c 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -2165,20 +2165,26 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, * - RST drops connection only if SEG.SEQ == RCV.NXT. * - If RST is in window, we send challenge ACK. * - * Note: to take into account delayed ACKs, we should - * test against last_ack_sent instead of rcv_nxt. + * Note 1: to take into account delayed ACKs, we should + * test against last_ack_sent in addition to rcv_nxt. * Note 2: we handle special case of closed window, not * covered by the RFC. + * Note 3 (XXXMT): check against rcv_adv instead of + * tp->rcv_nxt + tp->rcv_wnd. */ - if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) && - SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) || - (tp->rcv_wnd == 0 && tp->last_ack_sent == th->th_seq)) { + if ((tp->rcv_wnd > 0 && + SEQ_GEQ(th->th_seq, tp->last_ack_sent) && + SEQ_LT(th->th_seq, tp->rcv_nxt + tp->rcv_wnd)) || + (tp->rcv_wnd == 0 && + (tp->last_ack_sent == th->th_seq || + tp->rcv_nxt == th->th_seq))) { KASSERT(tp->t_state != TCPS_SYN_SENT, ("%s: TH_RST for TCPS_SYN_SENT th %p tp %p", __func__, th, tp)); if (V_tcp_insecure_rst || - tp->last_ack_sent == th->th_seq) { + tp->last_ack_sent == th->th_seq || + tp->rcv_nxt == th->th_seq) { TCPSTAT_INC(tcps_drops); /* Drop the connection. */ switch (tp->t_state) { diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c index 8b9a30a86397..28bb901dfdbf 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.c +++ b/sys/netinet/tcp_stacks/rack_bbr_common.c @@ -709,18 +709,24 @@ __ctf_process_rst(struct mbuf *m, struct tcphdr *th, struct socket *so, /* * RFC5961 Section 3.2 * - * - RST drops connection only if SEG.SEQ == RCV.NXT. - If RST is in - * window, we send challenge ACK. + * - RST drops connection only if SEG.SEQ == RCV.NXT. + * - If RST is in window, we send challenge ACK. * - * Note: to take into account delayed ACKs, we should test against - * last_ack_sent instead of rcv_nxt. Note 2: we handle special case - * of closed window, not covered by the RFC. + * Note 1: to take into account delayed ACKs, we should + * test against last_ack_sent in addition to rcv_nxt. + * Note 2: we handle special case of closed window, not + * covered by the RFC. + * Note 3 (XXXMT): check against rcv_adv instead of + * tp->rcv_nxt + tp->rcv_wnd. */ int dropped = 0; - if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) && - SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) || - (tp->rcv_wnd == 0 && tp->last_ack_sent == th->th_seq)) { + if ((tp->rcv_wnd > 0 && + SEQ_GEQ(th->th_seq, tp->last_ack_sent) && + SEQ_LT(th->th_seq, tp->rcv_nxt + tp->rcv_wnd)) || + (tp->rcv_wnd == 0 && + (tp->last_ack_sent == th->th_seq || + tp->rcv_nxt == th->th_seq))) { KASSERT(tp->t_state != TCPS_SYN_SENT, ("%s: TH_RST for TCPS_SYN_SENT th %p tp %p", __func__, th, tp));