Netdev List
 help / color / mirror / Atom feed
* [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK
@ 2026-11-27 10:50 syzbot
  2026-11-28 22:01 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2026-11-27 10:50 UTC (permalink / raw)
  To: syzkaller-bugs, Krystian Kaniewski, coreteam, David S. Miller,
	Eric Dumazet, Florian Westphal, Jakub Kicinski, netdev,
	netfilter-devel, Paolo Abeni, Pablo Neira Ayuso,
	Fernando Fernandez Mancera
  Cc: horms, phil, syzbot

From: Krystian Kaniewski <krystianmkaniewski@gmail.com>

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: syzbot+55141a0ffa0d17f01c71@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=55141a0ffa0d17f01c71
Link: https://syzkaller.appspot.com/ai_job?id=19d80d6e-8025-483e-ac1b-da92f0b2dde3
Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>

---
diff --git a/net/netfilter/nft_synproxy.c b/net/netfilter/nft_synproxy.c
index 554a96a00..aa8dea698 100644
--- a/net/netfilter/nft_synproxy.c
+++ b/net/netfilter/nft_synproxy.c
@@ -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
-- 
See https://goo.gle/syzbot-ai-patches for information about AI-generated patches.
The person who has signed off on the patch is responsible for
addressing comments.
syzbot engineers can be reached at syzkaller@googlegroups.com.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK
  2026-11-27 10:50 [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK syzbot
@ 2026-11-28 22:01 ` Pablo Neira Ayuso
  2026-11-30 12:17   ` Krystian Kaniewski
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-28 22:01 UTC (permalink / raw)
  To: syzbot
  Cc: syzkaller-bugs, Krystian Kaniewski, coreteam, David S. Miller,
	Eric Dumazet, Florian Westphal, Jakub Kicinski, netdev,
	netfilter-devel, Paolo Abeni, Fernando Fernandez Mancera, horms,
	phil, syzbot

On Fri, Nov 27, 2026 at 10:50:14AM +0000, syzbot wrote:
> From: Krystian Kaniewski <krystianmkaniewski@gmail.com>
> 
> 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.

This patch is a duplicate, there is a patch to address this in the ML.

> Fixes: ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support")
> Assisted-by: Gemini:gemini-4-hydrogen Gemini:gemini-3.8-flash syzbot
> Reported-by: syzbot+55141a0ffa0d17f01c71@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=55141a0ffa0d17f01c71
> Link: https://syzkaller.appspot.com/ai_job?id=19d80d6e-8025-483e-ac1b-da92f0b2dde3
> Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
> 
> ---
> diff --git a/net/netfilter/nft_synproxy.c b/net/netfilter/nft_synproxy.c
> index 554a96a00..aa8dea698 100644
> --- a/net/netfilter/nft_synproxy.c
> +++ b/net/netfilter/nft_synproxy.c
> @@ -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
> -- 
> See https://goo.gle/syzbot-ai-patches for information about AI-generated patches.
> The person who has signed off on the patch is responsible for
> addressing comments.
> syzbot engineers can be reached at syzkaller@googlegroups.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK
  2026-11-28 22:01 ` Pablo Neira Ayuso
@ 2026-11-30 12:17   ` Krystian Kaniewski
  2026-11-30 13:58     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Krystian Kaniewski @ 2026-11-30 12:17 UTC (permalink / raw)
  To: Pablo Neira Ayuso, syzbot
  Cc: syzkaller-bugs, coreteam, David S. Miller, Eric Dumazet,
	Florian Westphal, Jakub Kicinski, netdev, netfilter-devel,
	Paolo Abeni, Fernando Fernandez Mancera, horms, phil, syzbot

On 11/28/26 23:01, Pablo Neira Ayuso wrote:
> On Fri, Nov 27, 2026 at 10:50:14AM +0000, syzbot wrote:
>> From: Krystian Kaniewski <krystianmkaniewski@gmail.com>
>>
>> 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.
> 
> This patch is a duplicate, there is a patch to address this in the ML.
> 

Thanks, Pablo. I agree that this addresses the same bug as Nguyen's
patch:

https://lore.kernel.org/netfilter-devel/20261005151257.9128-1-ngocthang2710.1999@gmail.com/

I did not notice that posting before submitting this patch. Sorry for
the duplicate.

One difference is that this version enforces the protocol-independent
TCP flag invariant once in nft_synproxy_do_eval(), before the IPv4 and
IPv6 dispatch, instead of duplicating the same checks in both protocol
helpers. This also prevents the two paths from diverging later.

Would you prefer to fold that form into the existing patch? Otherwise,
please disregard this submission as a duplicate.
-- 
Krystian Kaniewski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK
  2026-11-30 12:17   ` Krystian Kaniewski
@ 2026-11-30 13:58     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-30 13:58 UTC (permalink / raw)
  To: Krystian Kaniewski
  Cc: syzbot, syzkaller-bugs, coreteam, David S. Miller, Eric Dumazet,
	Florian Westphal, Jakub Kicinski, netdev, netfilter-devel,
	Paolo Abeni, Fernando Fernandez Mancera, horms, phil, syzbot

On Mon, Nov 30, 2026 at 01:17:22PM +0100, Krystian Kaniewski wrote:
> On 11/28/26 23:01, Pablo Neira Ayuso wrote:
> > On Fri, Nov 27, 2026 at 10:50:14AM +0000, syzbot wrote:
> >> From: Krystian Kaniewski <krystianmkaniewski@gmail.com>
> >>
> >> 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.
> > 
> > This patch is a duplicate, there is a patch to address this in the ML.
> > 
> 
> Thanks, Pablo. I agree that this addresses the same bug as Nguyen's
> patch:
> 
> https://lore.kernel.org/netfilter-devel/20261005151257.9128-1-ngocthang2710.1999@gmail.com/

Actually, there is a patch before that patch which already addresses
this issue by Fernando F. Mancera.

> I did not notice that posting before submitting this patch. Sorry for
> the duplicate.
> 
> One difference is that this version enforces the protocol-independent
> TCP flag invariant once in nft_synproxy_do_eval(), before the IPv4 and
> IPv6 dispatch, instead of duplicating the same checks in both protocol
> helpers. This also prevents the two paths from diverging later.
> 
> Would you prefer to fold that form into the existing patch? Otherwise,
> please disregard this submission as a duplicate.
> -- 
> Krystian Kaniewski

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 10:50 [PATCH] netfilter: nft_synproxy: only handle a plain SYN or a plain ACK syzbot
2026-11-28 22:01 ` Pablo Neira Ayuso
2026-11-30 12:17   ` Krystian Kaniewski
2026-11-30 13:58     ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox