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=1796073955; b=CEVON2s0+5gZJizinHQivlu5x0DeUVxsyaV+DIeHZaQExnvAXRdqF1PvoIHsh6cXMSD/ qvI/Oir0ZTnwFUYFAPRfmTMGe/xWPF8Scy3R6/zLaBj6kXVAnxyg+zbR6lF8lCt40BmTt /xN4TxXdORhWUvEc9Zx/p9sWb/l1xCGSF6zI8a4e2pUqUp7QjqJE8mv21+eUW11+QPaKo 8CmculqwjZvW/4q3Xl+PhfuGZ0CK6jzdd3r3eSogeBjuqbcTvCjX9ln0bbtjoip1pN7dj AC9jcEuWFEbasLYAs40f5nSBnurKsfu5Gsa6hagaMzGV9XeqhmZznqCt77819EU05hg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796073955; h=DMARC-Filter:DKIM-Signature:Received:From:To: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=HlDF2NMdnsL38G50D/d6WKcVLd1NcDgzDYAE13r5zFd9CYb9iArFHclYBak+4V5rlfQG GEywoso9KWtxHy3qf4YibwZJGld5ac+Rej54JY1aCjlgn6nY/HS95LSSi6qg6Hrp9+16s n/rdW3Gap0lLVs1Lcm+asq19q5XcvhqQvtIonf5CJO5psV91wTeLnvYWT1y/tLqtSl9qy TMd2tRn3hYnXOfxtWZRixynVBrfnTJCKAjU8pAZHFSP+3W3/z1T5/stUj4D6GcdMOZ7ij qp94FtfPXtm2O5derLNg9eBKjiEpnRN+KviYLCt0npyBT1ErOHY85+HqJa85Eer/u3A== 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=qoojM8Jb; 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 129E3606A325 for ; Mon, 30 Nov 2026 21:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 129E3606A325 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=qoojM8Jb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1796073952; bh=3lK7ep+f78JKdu6ySuF7g0ystKCy9AVfiPCXUh6ThcM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qoojM8JbWeXwRnPKL44Z0ypEs/0OI1KPBo3fW7Oh8je640OD3eYY4/of9ZQJvDrlg pLM/VQ9gSaD2V1qaHyrH/VsUwI89lFuYC4Qyy7lrU9nedkRiQSS5BgntjkkmzDDsUV K9LwZ0oRQJ9wvk6R4vnAjbPfRXSYDgHZ85zAXkot1gnMsNjM5nAOkyXh5f4gR1rrjO 8Hl0m/c7+5qESSmp3qov6KUPoHnjHHA0gUXG4zAk4U3uVeZASQsVENo8QvHH+hs0hX S0Pjv0wJEOYQMS+ulp/Pz0sG1kvlktsFUtDcPOf8FOklAcEsM4ifTileWjW30uBR8t 4qNfKSKAOXwfQ== Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 178486008D for ; Mon, 30 Nov 2026 22:25:52 +0100 (CET) From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH net 09/10] netfilter: synproxy: fix double tsoff application in server ACK TSecr Date: Mon, 30 Nov 2026 22:25:38 +0100 Message-ID: <20261130212539.992130-10-pablo@netfilter.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130212539.992130-1-pablo@netfilter.org> References: <20261130212539.992130-1-pablo@netfilter.org> X-Mailing-List: netfilter-devel@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