From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795910865; b=B4YyZ2xFzIZ69CoqCpPOX0PiFt8aBwEqsfDgHX96Q5AwurDandYhEKOvrN+ucBkQwLXm ltwBIwJG4mYbTFVxG9JJEmaQZG2qX6SuKCnm//bYVdiP2cYE0UZWTxY56Gpz2W0m9H3l3 f9nqFGt+j1d5rsR7kHx7WWaBVj0gq7QQOVuZOaoB/ToPDzVIi2Z7mqNuAK5uZ/x+k0/LY sMPOF9+6exreC4xefNV36g7nnWj7FX9pQrX5Y2cVH5bn0KFZ1kNYVkANOGrazaLrfhEcx 5ot9CrZPZlzO/jPi2jmsjBMl7kODD22NfS1AbQQmb3bthAulkrdidVgdnULl96MDsnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910865; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version; bh=3lK7ep+f78JKdu6ySuF7g0ystKCy9AVfiPCXUh6ThcM=; b=1dWbiE3ZmWWOMOwKIKpfKO+93sKI8ZtYo79/EhUN2S5ztHhl9NZn+4TvPdxDQg8elxSG rD137EhTmJJxQSWmkc8EM1wI57XOwT3wDtnrZPA0YR5X6XhwkCnHpMTOu8PyC9XEkX+b0 X1E6GIBufxFA5oDr/2Wv7LYlk4zuV6yOkQiVYCFMG/jEBmmhCOO1xtX+wic9CSH2shtFu NHCmmW3L6NsVsP6Vwz5+HkrAp8UCJ3qe5T/GdADXLS8d2CrdYfpG4H+Q8LfUxzVldx441 TcaJ51Nf8zx8MJM/pLiky0NBDFM6DZZziaJbYC7o8WYGDdYDjYGDDBImh1eZj3zgjPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=wWuR7sg7; arc=none smtp.remote-ip=217.70.190.124 Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2C6A606A69A; Sun, 29 Nov 2026 00:07:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2C6A606A69A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=wWuR7sg7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1795910863; bh=3lK7ep+f78JKdu6ySuF7g0ystKCy9AVfiPCXUh6ThcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wWuR7sg72m+uAhkNb7rstUBh00aqWw9/1n9E+ZoZAvjx59pNRElQQ7DBtn5bGCjIF qXQAMRPsVgpy1bEeRUqs0XvWVoe+o+Rw1XxcKI23msQFBwShoJ1I6maBRgChItFToH N2xdhsItk5cTJAfU3UIvu7y03vo5J1VXq92GpZwv3CRvB6GtwjzZlg7EDffWleM084 MSAuS52+C4EWHSXB/cqnrdddLFXqCSQfZX6vXujUBO+icTvZlqpoMkSD2q5bvpNmA3 1sANdCgyf+C3UypYOEoE6fvAidyKMgABFa4L9DUxb2DFg1D1RxGSHx179AoE0p2iUy TJwA/9WpMsBFw== Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 7C000601B3; Sun, 29 Nov 2026 01:07:42 +0100 (CET) From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg Subject: [PATCH net 09/14] netfilter: synproxy: fix double tsoff application in server ACK TSecr Date: Sun, 29 Nov 2026 01:07:19 +0100 Message-ID: <20261129000724.797425-10-pablo@netfilter.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261129000724.797425-1-pablo@netfilter.org> References: <20261129000724.797425-1-pablo@netfilter.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Florian Westphal When SYNPROXY is active with timestamp options enabled, the handshake ACK sent to the backend carries a TSecr that is off by synproxy->tsoff. The code swaps tsval and tsecr before calling synproxy_send_server_ack(). The ACK is built with the correct TSecr (the server's TSval), but it re-enters ipv4_synproxy_hook() on its way out, where synproxy_tstamp_adjust() adds tsoff to TSecr a second time. Since commit 3ba075278c11 ("tcp: be less liberal in TSEcr received while in SYN_RECV state") Linux TCP performs stricter validation and such backends will drops the ACK. This will delay connection establishment until the server SYN-ACK retransmit, which may take a few seconds. Replace the swap() by explicit initialisation of tsval/tsecr for both the server and client ACKs. Build the server ACK with TSecr pre-compensated (server TSval - tsoff), so that the adjustment on re-entry yields the server's actual TSval. Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target") Reported-and-tested-by: Dominik Shaim Ulrich Closes: https://lore.kernel.org/netfilter-devel/CAFvzkdAXBNAWcHFNo6akAo63Wd8B_jvhkt=AEmuLR9fgPBEfGg@mail.gmail.com/ Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_synproxy_core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c index 9dd681596c70..559db2c972f8 100644 --- a/net/netfilter/nf_synproxy_core.c +++ b/net/netfilter/nf_synproxy_core.c @@ -661,6 +661,7 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb, const struct ip_ct_tcp *state; struct tcphdr *th, _th; unsigned int thoff; + u32 tsval, tsecr; ct = nf_ct_get(skb, &ctinfo); if (!ct) @@ -742,13 +743,18 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb, NF_SYNPROXY_OPT_WSCALE | NF_SYNPROXY_OPT_SACK_PERM); - swap(opts.tsval, opts.tsecr); + tsval = opts.tsval; + tsecr = opts.tsecr; + + opts.tsval = tsecr; + opts.tsecr = tsval - synproxy->tsoff; synproxy_send_server_ack(net, state, skb, th, &opts); nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq)); nf_conntrack_event_cache(IPCT_SEQADJ, ct); - swap(opts.tsval, opts.tsecr); + opts.tsecr = tsecr; + opts.tsval = tsval; synproxy_send_client_ack(net, skb, th, &opts); consume_skb(skb); @@ -1093,6 +1099,7 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb, struct synproxy_options opts = {}; const struct ip_ct_tcp *state; struct tcphdr *th, _th; + u32 tsval, tsecr; __be16 frag_off; u8 nexthdr; int thoff; @@ -1181,13 +1188,18 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb, NF_SYNPROXY_OPT_WSCALE | NF_SYNPROXY_OPT_SACK_PERM); - swap(opts.tsval, opts.tsecr); + tsval = opts.tsval; + tsecr = opts.tsecr; + + opts.tsval = tsecr; + opts.tsecr = tsval - synproxy->tsoff; synproxy_send_server_ack_ipv6(net, state, skb, th, &opts); nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq)); nf_conntrack_event_cache(IPCT_SEQADJ, ct); - swap(opts.tsval, opts.tsecr); + opts.tsecr = tsecr; + opts.tsval = tsval; synproxy_send_client_ack_ipv6(net, skb, th, &opts); consume_skb(skb); -- 2.47.3