* [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching
@ 2026-11-24 17:28 syzbot
2026-11-25 14:42 ` Krystian Kaniewski
0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2026-11-24 17:28 UTC (permalink / raw)
To: syzkaller-upstream-moderation; +Cc: syzbot
In nft_synproxy_eval_v4() and nft_synproxy_eval_v6(), TCP control flags are
checked only with `if (tcp->syn)` and `else if (tcp->ack)` without
excluding other flags, unlike the xtables SYNPROXY targets
(`synproxy_tg4()` and `synproxy_tg6()`). As a result, a SYN+ACK (or SYN+FIN
/ SYN+RST) packet reaching `nft_synproxy` is misidentified as an initial
client SYN and causes `synproxy_send_client_synack()` or
`synproxy_send_client_synack_ipv6()` to reply with another SYN+ACK.
Likewise, FIN+ACK and RST+ACK packets enter the client ACK branch and can
be dropped with NF_DROP instead of continuing through the ruleset.
When an nftables rule evaluates `nft_synproxy` (either via the inline
expression or a stateful `NFT_OBJECT_SYNPROXY` object) on
`NF_INET_LOCAL_IN`, a local TCP SYN over loopback triggers
`nft_synproxy_eval_v4()` to send a SYN+ACK with swapped addresses and ports
and a fresh TTL via `synproxy_send_client_synack()`. When
`process_backlog()` in `NET_RX_SOFTIRQ` delivers that SYN+ACK back to
`NF_INET_LOCAL_IN`, `if (tcp->syn)` matches again, creating an infinite
SYN+ACK loop in softirq context. This saturates the CPUs, starves tasks
holding or waiting on `rtnl_mutex`, and triggers hung task warnings:
INFO: task kworker/R-ipv6_:60 blocked for more than 144 seconds.
Workqueue: ipv6_addrconf addrconf_dad_work
Call Trace:
__mutex_lock+0x7c4/0x15a0 kernel/locking/mutex.c:821
rtnl_net_lock include/linux/rtnetlink.h:134 [inline]
addrconf_dad_work+0x116/0x15c0 net/ipv6/addrconf.c:4256
NMI backtrace for cpu 1
__kfree_skb+0x5d/0x210 net/core/skbuff.c:1203
nft_synproxy_eval_v4+0x36a/0x4e0 net/netfilter/nft_synproxy.c:-1
nft_synproxy_do_eval+0x389/0x5d0 net/netfilter/nft_synproxy.c:142
expr_call_ops_eval net/netfilter/nf_tables_core.c:237 [inline]
nft_do_chain+0x48d/0x1b10 net/netfilter/nf_tables_core.c:285
nft_do_chain_ipv4+0x195/0x290 net/netfilter/nft_chain_filter.c:24
process_backlog+0xa6b/0x18b0 net/core/dev.c:6915
Fix this by enforcing the same strict TCP flag checks as `ipt_SYNPROXY` and
`ip6t_SYNPROXY` in both `nft_synproxy_eval_v4()` and
`nft_synproxy_eval_v6()`: require `tcp->syn && !(tcp->ack || tcp->fin ||
tcp->rst)` for the initial SYN branch and `tcp->ack && !(tcp->fin ||
tcp->rst || tcp->syn)` for the client ACK branch. Excluding `tcp->syn` from
the ACK branch ensures SYN+ACK packets are not passed to
`synproxy_recv_client_ack()` or `synproxy_recv_client_ack_ipv6()` and
dropped, while unrelated control packets fall through with
`regs->verdict.code` left as `NFT_CONTINUE`.
Fixes: ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support")
Assisted-by: Gemini:gemini-4-hydrogen Gemini:gemini-4-carbon syzbot
Reported-by: syzbot+55141a0ffa0d17f01c71@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=55141a0ffa0d17f01c71
Link: https://syzkaller.appspot.com/ai_job?id=d414ed29-2420-4a5b-b4af-0b7b7dc8df30
To: <coreteam@netfilter.org>
To: "David S. Miller" <davem@davemloft.net>
To: "Eric Dumazet" <edumazet@kernel.org>
To: "Florian Westphal" <fw@strlen.de>
To: "Jakub Kicinski" <kuba@kernel.org>
To: <netdev@vger.kernel.org>
To: <netfilter-devel@vger.kernel.org>
To: "Paolo Abeni" <pabeni@redhat.com>
To: "Pablo Neira Ayuso" <pablo@netfilter.org>
To: "Fernando Fernandez Mancera" <ffmancera@riseup.net>
Cc: "Simon Horman" <horms@kernel.org>
Cc: "Phil Sutter" <phil@nwl.cc>
---
diff --git a/net/netfilter/nft_synproxy.c b/net/netfilter/nft_synproxy.c
index 554a96a00..ad43faf1d 100644
--- a/net/netfilter/nft_synproxy.c
+++ b/net/netfilter/nft_synproxy.c
@@ -53,13 +53,13 @@ static void nft_synproxy_eval_v4(const struct nft_synproxy *priv,
struct synproxy_net *snet = synproxy_pernet(net);
struct sk_buff *skb = pkt->skb;
- if (tcp->syn) {
+ if (tcp->syn && !(tcp->ack || tcp->fin || tcp->rst)) {
/* Initial SYN from client */
nft_synproxy_tcp_options(opts, tcp, snet, &info);
synproxy_send_client_synack(net, skb, tcp, opts);
consume_skb(skb);
regs->verdict.code = NF_STOLEN;
- } else if (tcp->ack) {
+ } else if (tcp->ack && !(tcp->fin || tcp->rst || tcp->syn)) {
/* ACK from client */
if (synproxy_recv_client_ack(net, skb, tcp, opts,
ntohl(tcp->seq))) {
@@ -84,13 +84,13 @@ static void nft_synproxy_eval_v6(const struct nft_synproxy *priv,
struct synproxy_net *snet = synproxy_pernet(net);
struct sk_buff *skb = pkt->skb;
- if (tcp->syn) {
+ if (tcp->syn && !(tcp->ack || tcp->fin || tcp->rst)) {
/* Initial SYN from client */
nft_synproxy_tcp_options(opts, tcp, snet, &info);
synproxy_send_client_synack_ipv6(net, skb, tcp, opts);
consume_skb(skb);
regs->verdict.code = NF_STOLEN;
- } else if (tcp->ack) {
+ } else if (tcp->ack && !(tcp->fin || tcp->rst || tcp->syn)) {
/* ACK from client */
if (synproxy_recv_client_ack_ipv6(net, skb, tcp, opts,
ntohl(tcp->seq))) {
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
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 syzkaller@googlegroups.com.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching
2026-11-24 17:28 [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching syzbot
@ 2026-11-25 14:42 ` Krystian Kaniewski
0 siblings, 0 replies; 2+ messages in thread
From: Krystian Kaniewski @ 2026-11-25 14:42 UTC (permalink / raw)
To: syzbot, syzkaller-upstream-moderation; +Cc: syzbot
On 11/24/26 18:28, syzbot wrote:
> In nft_synproxy_eval_v4() and nft_synproxy_eval_v6(), TCP control flags are
> checked only with `if (tcp->syn)` and `else if (tcp->ack)` without
> excluding other flags, unlike the xtables SYNPROXY targets
> (`synproxy_tg4()` and `synproxy_tg6()`). As a result, a SYN+ACK (or SYN+FIN
> / SYN+RST) packet reaching `nft_synproxy` is misidentified as an initial
> client SYN and causes `synproxy_send_client_synack()` or
> `synproxy_send_client_synack_ipv6()` to reply with another SYN+ACK.
> Likewise, FIN+ACK and RST+ACK packets enter the client ACK branch and can
> be dropped with NF_DROP instead of continuing through the ruleset.
>
> When an nftables rule evaluates `nft_synproxy` (either via the inline
> expression or a stateful `NFT_OBJECT_SYNPROXY` object) on
> `NF_INET_LOCAL_IN`, a local TCP SYN over loopback triggers
> `nft_synproxy_eval_v4()` to send a SYN+ACK with swapped addresses and ports
> and a fresh TTL via `synproxy_send_client_synack()`. When
> `process_backlog()` in `NET_RX_SOFTIRQ` delivers that SYN+ACK back to
> `NF_INET_LOCAL_IN`, `if (tcp->syn)` matches again, creating an infinite
> SYN+ACK loop in softirq context. This saturates the CPUs, starves tasks
> holding or waiting on `rtnl_mutex`, and triggers hung task warnings:
>
> INFO: task kworker/R-ipv6_:60 blocked for more than 144 seconds.
> Workqueue: ipv6_addrconf addrconf_dad_work
> Call Trace:
> __mutex_lock+0x7c4/0x15a0 kernel/locking/mutex.c:821
> rtnl_net_lock include/linux/rtnetlink.h:134 [inline]
> addrconf_dad_work+0x116/0x15c0 net/ipv6/addrconf.c:4256
>
> NMI backtrace for cpu 1
> __kfree_skb+0x5d/0x210 net/core/skbuff.c:1203
> nft_synproxy_eval_v4+0x36a/0x4e0 net/netfilter/nft_synproxy.c:-1
> nft_synproxy_do_eval+0x389/0x5d0 net/netfilter/nft_synproxy.c:142
> expr_call_ops_eval net/netfilter/nf_tables_core.c:237 [inline]
> nft_do_chain+0x48d/0x1b10 net/netfilter/nf_tables_core.c:285
> nft_do_chain_ipv4+0x195/0x290 net/netfilter/nft_chain_filter.c:24
> process_backlog+0xa6b/0x18b0 net/core/dev.c:6915
>
> Fix this by enforcing the same strict TCP flag checks as `ipt_SYNPROXY` and
> `ip6t_SYNPROXY` in both `nft_synproxy_eval_v4()` and
> `nft_synproxy_eval_v6()`: require `tcp->syn && !(tcp->ack || tcp->fin ||
> tcp->rst)` for the initial SYN branch and `tcp->ack && !(tcp->fin ||
> tcp->rst || tcp->syn)` for the client ACK branch. Excluding `tcp->syn` from
> the ACK branch ensures SYN+ACK packets are not passed to
> `synproxy_recv_client_ack()` or `synproxy_recv_client_ack_ipv6()` and
> dropped, while unrelated control packets fall through with
> `regs->verdict.code` left as `NFT_CONTINUE`.
>
> Fixes: ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support")
> Assisted-by: Gemini:gemini-4-hydrogen Gemini:gemini-4-carbon syzbot
> Reported-by: syzbot+55141a0ffa0d17f01c71@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=55141a0ffa0d17f01c71
> Link: https://syzkaller.appspot.com/ai_job?id=d414ed29-2420-4a5b-b4af-0b7b7dc8df30
> To: <coreteam@netfilter.org>
> To: "David S. Miller" <davem@davemloft.net>
> To: "Eric Dumazet" <edumazet@kernel.org>
> To: "Florian Westphal" <fw@strlen.de>
> To: "Jakub Kicinski" <kuba@kernel.org>
> To: <netdev@vger.kernel.org>
> To: <netfilter-devel@vger.kernel.org>
> To: "Paolo Abeni" <pabeni@redhat.com>
> To: "Pablo Neira Ayuso" <pablo@netfilter.org>
> To: "Fernando Fernandez Mancera" <ffmancera@riseup.net>
> Cc: "Simon Horman" <horms@kernel.org>
> Cc: "Phil Sutter" <phil@nwl.cc>
>
> ---
> diff --git a/net/netfilter/nft_synproxy.c b/net/netfilter/nft_synproxy.c
> index 554a96a00..ad43faf1d 100644
> --- a/net/netfilter/nft_synproxy.c
> +++ b/net/netfilter/nft_synproxy.c
> @@ -53,13 +53,13 @@ static void nft_synproxy_eval_v4(const struct nft_synproxy *priv,
> struct synproxy_net *snet = synproxy_pernet(net);
> struct sk_buff *skb = pkt->skb;
>
> - if (tcp->syn) {
> + if (tcp->syn && !(tcp->ack || tcp->fin || tcp->rst)) {
> /* Initial SYN from client */
> nft_synproxy_tcp_options(opts, tcp, snet, &info);
> synproxy_send_client_synack(net, skb, tcp, opts);
> consume_skb(skb);
> regs->verdict.code = NF_STOLEN;
> - } else if (tcp->ack) {
> + } else if (tcp->ack && !(tcp->fin || tcp->rst || tcp->syn)) {
> /* ACK from client */
> if (synproxy_recv_client_ack(net, skb, tcp, opts,
> ntohl(tcp->seq))) {
> @@ -84,13 +84,13 @@ static void nft_synproxy_eval_v6(const struct nft_synproxy *priv,
> struct synproxy_net *snet = synproxy_pernet(net);
> struct sk_buff *skb = pkt->skb;
>
> - if (tcp->syn) {
> + if (tcp->syn && !(tcp->ack || tcp->fin || tcp->rst)) {
> /* Initial SYN from client */
> nft_synproxy_tcp_options(opts, tcp, snet, &info);
> synproxy_send_client_synack_ipv6(net, skb, tcp, opts);
> consume_skb(skb);
> regs->verdict.code = NF_STOLEN;
> - } else if (tcp->ack) {
> + } else if (tcp->ack && !(tcp->fin || tcp->rst || tcp->syn)) {
> /* ACK from client */
> if (synproxy_recv_client_ack_ipv6(net, skb, tcp, opts,
> ntohl(tcp->seq))) {
>
>
> base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
Move TCP flag eligibility into `nft_synproxy_do_eval()` after
`synproxy_parse_options()` and before the IPv4 and IPv6 dispatch. Return
without changing the nftables verdict when SYN and ACK have the same
value, or when FIN or RST is set:
if (tcp->syn == tcp->ack || tcp->fin || tcp->rst)
return;
Keep the family evaluators focused on packet construction and cookie
processing so this family-neutral policy is defined only once. Preserve
the existing checksum, header, and option error order, together with the
current clean SYN and clean ACK behavior.
Rewrite the commit message to remove the quoted hung-task and NMI excerpt.
That exact excerpt does not match the retained crash report. Keep the
supported explanation that a generated SYN+ACK can return through the same
input rule and sustain a feedback loop in softirq context. Preserve the
verified `Fixes` tag, syzbot report and job links, and existing Gemini
provenance. Do not change any other behavior.
--
Krystian Kaniewski
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 17:28 [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching syzbot
2026-11-25 14:42 ` Krystian Kaniewski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.