From nobody Sun Oct 5 13:30:15 2025 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 4cfjvC5skhz69tkT; Sun, 05 Oct 2025 13:30:15 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cfjvC4S7Kz3thG; Sun, 05 Oct 2025 13:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759671015; 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=ymFEETexMHqb+Gjg68syTz1anKOBu/sCbVoHxuWWR9w=; b=fBcOiKL7aYW/UNGv263onAa7e1Oxao2Ugf0V3Z9T5Ru0UFo5Tx9Gz6LeCJ/iRzZVIYhX/H CMMytQ3nAlxO3QKI/+pLUcc+4GL3nzmPVpmcZbfzc7/bDO7eRvUTvVkzj77MUYGHO1MM1e YS8TrOweJgpM6bzSy4M7cEaC3dWkIDfYSnr9NvuyhvZXd3O/GZAZN43/ESlFQ/Fj1B5Ism BreCJw0F2OwB2HVUMplIwHrJtS9W3N9jMT44NXvpCru5cWbDZaL1uhc6YZ3j3BCMzuyQiJ IhWpzIg7fO9xYX0snDfXqeVDlRqjbE2iSR4mUddAmIeQdRNPHFEktPvF9XcltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759671015; 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=ymFEETexMHqb+Gjg68syTz1anKOBu/sCbVoHxuWWR9w=; b=UHB8JhCbIeJLjV8hpxZZbuc+f4C+d/C5VoF9iLtytd8L6t5lGl+XtM/l+6Uam1o0XyDAj1 PVdv2NWNH6tzrhWDBoPuYpWjWcQJpc4wdxmJvxxYNb2rmxZQ4CfqkddK/6/kGlYwhtdEbx dDstiZzBVRYq5mD+kGP/YGIWQKAqp0dI4ZyE8cRzxGdoITAy3jusCLjpEpKqKKIszcaTYL eDke3wYeKHKrnmxQYKCMNhcWqJO9T996bBSjvk+ouxFqcTbKjcWSydszAz9ZklIBq/woRg xeysEoZR47EVIZWA8quw0h6AtmsXj42ISUx4OZZrIHFyESQPYiDqDOW03q+Mmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759671015; a=rsa-sha256; cv=none; b=Rj8Dlpek+F+RXppkaDfqzqonRP99ug+URiwLtqtKHcZHmR+6MyFohHA8Mggt2nJgnqMHCP OoWt1KOMjpoG/v8Y1X0AJdO66dehnP6DyUFMNqlYZXEgPybXLFEFe1a/7KMSlEhs/31wGX gSkNCMkIDIrDFtyMtXF0SFu3V0N3mO1r3TfQ02KnoxfiF+VoRZ9jcnT/mtzYSA/n2OTqKa G4Ft232+iy0Oo7kySzDoJXa4kd0sPIBr2CLXFG6cqQvE7wO8akJIreb9v9TSXmCO9q+qv2 jA5xZL0mO0INtjUCVGzGX2MbW+998GvicCNux+k24umOBYsyIxyGZEJXMl1EbQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cfjvC3Qf3zN3; Sun, 05 Oct 2025 13:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 595DUFRT002779; Sun, 5 Oct 2025 13:30:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 595DUF8c002775; Sun, 5 Oct 2025 13:30:15 GMT (envelope-from git) Date: Sun, 5 Oct 2025 13:30:15 GMT Message-Id: <202510051330.595DUF8c002775@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 0ca910a682c3 - stable/15 - tcp: cleanup syncache_expand() 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 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/15 X-Git-Reftype: branch X-Git-Commit: 0ca910a682c332feee35b431a5097440bbf65bc7 Auto-Submitted: auto-generated The branch stable/15 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=0ca910a682c332feee35b431a5097440bbf65bc7 commit 0ca910a682c332feee35b431a5097440bbf65bc7 Author: Michael Tuexen AuthorDate: 2025-10-01 19:14:23 +0000 Commit: Michael Tuexen CommitDate: 2025-10-05 13:29:55 +0000 tcp: cleanup syncache_expand() Only validate SEG.SEQ and SEG.ACK when processing a real SYN-cache entry. In the SYN-cookie case, these conditions are always true, since the SYN-cache entry on the stack is constructed from the incoming TCP segment. While there, fix the logging messages. Reviewed by: Nick Banks Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52816 (cherry picked from commit 3034fa3d4321fdc487428c9050711de9ce234567) --- sys/netinet/tcp_syncache.c | 52 ++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 72e9dccea9a5..518cef66e7fa 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1260,6 +1260,35 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, return (-1); /* Do not send RST */ } } + + /* + * SEG.ACK validation: + * SEG.ACK must match our initial send sequence number + 1. + */ + if (th->th_ack != sc->sc_iss + 1) { + SCH_UNLOCK(sch); + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) + log(LOG_DEBUG, "%s; %s: ACK %u != ISS+1 %u, " + "segment rejected\n", + s, __func__, th->th_ack, sc->sc_iss + 1); + goto failed; + } + + /* + * SEG.SEQ validation: + * The SEG.SEQ must be in the window starting at our + * initial receive sequence number + 1. + */ + if (SEQ_LEQ(th->th_seq, sc->sc_irs) || + SEQ_GT(th->th_seq, sc->sc_irs + sc->sc_wnd)) { + SCH_UNLOCK(sch); + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) + log(LOG_DEBUG, "%s; %s: SEQ %u != IRS+1 %u, " + "segment rejected\n", + s, __func__, th->th_seq, sc->sc_irs + 1); + goto failed; + } + TAILQ_REMOVE(&sch->sch_bucket, sc, sc_hash); sch->sch_length--; #ifdef TCP_OFFLOAD @@ -1272,29 +1301,6 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, SCH_UNLOCK(sch); } - /* - * Segment validation: - * ACK must match our initial sequence number + 1 (the SYN|ACK). - */ - if (th->th_ack != sc->sc_iss + 1) { - if ((s = tcp_log_addrs(inc, th, NULL, NULL))) - log(LOG_DEBUG, "%s; %s: ACK %u != ISS+1 %u, segment " - "rejected\n", s, __func__, th->th_ack, sc->sc_iss); - goto failed; - } - - /* - * The SEQ must fall in the window starting at the received - * initial receive sequence number + 1 (the SYN). - */ - if (SEQ_LEQ(th->th_seq, sc->sc_irs) || - SEQ_GT(th->th_seq, sc->sc_irs + sc->sc_wnd)) { - if ((s = tcp_log_addrs(inc, th, NULL, NULL))) - log(LOG_DEBUG, "%s; %s: SEQ %u != IRS+1 %u, segment " - "rejected\n", s, __func__, th->th_seq, sc->sc_irs); - goto failed; - } - *lsop = syncache_socket(sc, *lsop, m); if (__predict_false(*lsop == NULL)) {