Skip to contentSkip to conversation

netfilter: nft_synproxy: only handle a plain SYN or a plain ACK

RFC PATCH syzbot 1 participant 1 message Nov 26

Subsystems (2)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

nft_synproxy_eval_v4() and nft_synproxy_eval_v6() check tcp->syn and tcp->ack without excluding other TCP control flags, unlike the xtables SYNPROXY targets. As a result, a SYN+ACK (or SYN+FIN / SYN+RST) packet reaching nft_synproxy is misidentified as an initial client SYN and triggers another SYN+ACK reply, while FIN+ACK and RST+ACK packets enter the client ACK branch and can be dropped with NF_DROP instead of continuing through the ruleset.

On loopback, when an nftables input rule evaluates nft_synproxy, a local SYN causes it to send a SYN+ACK back over loopback, which hits the same rule again and matches tcp->syn. This creates an infinite SYN+ACK feedback loop in softirq context that saturates the CPUs, starves tasks holding or waiting on rtnl_mutex, and triggers hung task warnings (such as "INFO: task kworker/R-ipv6_:60 blocked for more than 143 seconds" in addrconf_dad_work).

Fix this in nft_synproxy_do_eval() by returning early when tcp->syn == tcp->ack || tcp->fin || tcp->rst before dispatching to nft_synproxy_eval_v4() or nft_synproxy_eval_v6(). This ensures nft_synproxy only handles a plain SYN or a plain ACK (without FIN or RST), while valid TCP segments outside the client handshake such as SYN+ACK, FIN+ACK, and RST+ACK—as well as other segments with FIN, RST, or neither SYN nor ACK set—continue through the ruleset unchanged with regs->verdict.code left as NFT_CONTINUE.

Fixes ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support")
Assisted-by Gemini:gemini-4-hydrogen Gemini:gemini-3.8-flash syzbot
Reported-by [email protected]

To: <[email protected]>
To: "David S. Miller" <[email protected]>
To: "Eric Dumazet" <[email protected]>
To: "Florian Westphal" <[email protected]>
To: "Jakub Kicinski" <[email protected]>
To: <[email protected]>
To: <[email protected]>
To: "Paolo Abeni" <[email protected]>
To: "Pablo Neira Ayuso" <[email protected]>
To: "Fernando Fernandez Mancera" <[email protected]>
Cc: "Simon Horman" <[email protected]>
Cc: "Phil Sutter" <[email protected]>

---
v3:
- Updated the commit title and description to plain text without Markdown backticks.
- Simplified the description of the loopback SYN-ACK feedback loop.
- Clarified that valid TCP segments outside the client handshake (such as SYN+ACK, FIN+ACK, and RST+ACK) continue through the ruleset unchanged.

v2:
- Moved the strict TCP flag check from nft_synproxy_eval_v4() and nft_synproxy_eval_v6() into nft_synproxy_do_eval()
- Replaced the per-branch flag checks with if (tcp->syn == tcp->ack || tcp->fin || tcp->rst) return;
- Updated the commit message to match the new implementation and removed the quoted hung-task and NMI backtrace excerpt
https://lore.kernel.org/all/[email protected]/T/

v1:
https://lore.kernel.org/all/[email protected]/T/
---

net/netfilter/nft_synproxy.c +3 -0
index 554a96a00..aa8dea698 100644
@@ -137,6 +137,9 @@ static void nft_synproxy_do_eval(const struct nft_synproxy *priv,
 		return;
 	}
 
+	if (tcp->syn == tcp->ack || tcp->fin || tcp->rst)
+		return;
+
 	switch (skb->protocol) {
 	case htons(ETH_P_IP):
 		nft_synproxy_eval_v4(priv, regs, pkt, tcp, &_tcph, &opts);

base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f

Signature · 9 lines
This is an AI-generated patch subject to moderation.
Reply with '#syz upstream' to Sign-off the patch as a human author
and send it to the upstream kernel mailing lists.
Reply with '#syz reject' to reject it ('#syz unreject' to undo).

See https://goo.gle/syzbot-ai-patches for information about AI-generated patches.
You can comment on the patch as usual, syzbot will try to address
the comments and send a new version of the patch if necessary.
syzbot engineers can be reached at [email protected].