From nobody Tue Dec 19 19:24:55 2023 X-Original-To: dev-commits-src-main@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 4SvmqC6pZlz54msd; Tue, 19 Dec 2023 19:24:55 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SvmqC6559z3MGZ; Tue, 19 Dec 2023 19:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703013895; 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=U3Vw3nE4xIFotocGZq8mnf5qQ1pXbu6Tul9hsqw7+XI=; b=Fk1Ho5iWIC4GcuanunhuT6L5wH4JLI/Jwyq1nESESpVm465IdwUPG4AUN6ITF853hrz7Lx Vl2iYf3+plDQDcKE6QwHOnfo1E2Dfq7XHczqmZS4AaGEltkW750ZzK989gypN/gu3h5PvW Oqp+UJrjiAWr8mSUa2BT+BDNSoK4kmb2Fe5O8JyoHWWQDSQrACfIgsQSChwMn4gloriAFH 8cVEsE/ZyC9OomByeCZQESXcbsQ8z2uhkOHoMOA+pjhZTj0xR1N0TxVxgmuxohMRg0jc/q lCE3LPIQDzOor0EUPW+LvIXSYN4h6HoHCOhsfNfDkLq1Q0GonZUpmktdZGmR3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703013895; a=rsa-sha256; cv=none; b=Z1DRSAg3UvoM4FdOTDwfoXth9lowyIPQs4i8WVYXzeMtWnzuLw/RQ+gNpq4J4FejV64VeP CSz6Z2qsMPR5kbGy2AnPyIZtDFInCTnRHyX6kSZHGKwk4wDCUsXAgtNxgtN9oAscf8ws8G W8v0znb1F3yMIc8M4sKX+FQo9jXzHLgTiBgMRrNOncsNUSlqeVpse3lE2wLUgimCcz+N6U IlwPKq96UxGkNo9NGxyw3inV3jJVS5ok/D5W2/zpu5QgP84CfGErughw02ZBIHsljuu0HY oNlpkEpkkTf0nLLa79N/ohbUKROoGtjx8gFbbW94PPyxSsS7Jq4cEmiU+Zo4FQ== 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=1703013895; 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=U3Vw3nE4xIFotocGZq8mnf5qQ1pXbu6Tul9hsqw7+XI=; b=NQQVJNHR2ew9n/Dslq8TIy2b3VcKJ1ubGZPAx7Mm4JLOW+RkPYTSsfpbR9n1wXOdzfe5Dh 5HS87Bf8b5XMdU/I7TchBxqVW7v3dK+odHdcx00bx76Q7A6NcdWDE3oLPAougEsj8AYNMZ BYn7x1gd3W4YXPbw1cxmnLrbSMDA5ZvCFcMlvggrpFJsCCx55sMPXXV792vUumI2Y98NV6 V+ssEzMo49axzU7K6R/+DTeorlytwc+gjjqjHbOoindhtydkt0DqTBcvxafqwDFBTeVxBn lbtJixW7osFfKUSklt/r1AXNKpe3NdzHYWphH/hfb3ZwntaBY1orHDhgJgrXEA== 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 4SvmqC4kL0z3TW; Tue, 19 Dec 2023 19:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BJJOtFn016385; Tue, 19 Dec 2023 19:24:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BJJOtOQ016382; Tue, 19 Dec 2023 19:24:55 GMT (envelope-from git) Date: Tue, 19 Dec 2023 19:24:55 GMT Message-Id: <202312191924.3BJJOtOQ016382@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 513f2e2e7180 - main - tcp: always set tcp_tun_port to a correct value List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 513f2e2e7180202167ca2963d815d2a4c3ac0af9 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=513f2e2e7180202167ca2963d815d2a4c3ac0af9 commit 513f2e2e7180202167ca2963d815d2a4c3ac0af9 Author: Gleb Smirnoff AuthorDate: 2023-12-19 19:24:17 +0000 Commit: Gleb Smirnoff CommitDate: 2023-12-19 19:24:17 +0000 tcp: always set tcp_tun_port to a correct value The tcp_tun_port field that is used to pass port value between UDP and TCP in case of tunneling is a generic field that used to pass data between network layers. It can be contaminated on entry, e.g. by a VLAN tag set by a NIC driver. Explicily set it, so that it is zeroed out in a normal not-tunneled TCP. If it contains garbage, tcp_twcheck() later can enter wrong block of code and treat the packet as incorrectly tunneled one. On main and stable/14 that will end up with sending incorrect responses, but on stable/13 with ipfw(8) and pcb-matching rules it may end up in a panic. This is a minimal conservative patch to be merged to stable branches. Later we may redesign this. PR: 275169 Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D43065 --- sys/netinet/tcp_input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 05f9a4a9726a..ab8fc4b4a3e4 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -633,6 +633,7 @@ tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port) to.to_flags = 0; TCPSTAT_INC(tcps_rcvtotal); + m->m_pkthdr.tcp_tun_port = port; #ifdef INET6 if (isipv6) { ip6 = mtod(m, struct ip6_hdr *);