From: Krystian Kaniewski <krystianmkaniewski@gmail.com>
To: syzbot <syzbot@kernel.org>,
syzkaller-upstream-moderation@googlegroups.com
Cc: syzbot@lists.linux.dev
Subject: Re: [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching
Date: Wed, 25 Nov 2026 15:42:00 +0100 [thread overview]
Message-ID: <c1da196b-c3b0-4701-9cbf-bf357bfebfc8@gmail.com> (raw)
In-Reply-To: <96d0756e-28cd-4b99-b0c7-17698acc8276@mail.kernel.org>
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
prev parent reply other threads:[~2026-11-25 14:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:28 [PATCH RFC] netfilter: nft_synproxy: enforce strict TCP flag matching syzbot
2026-11-25 14:42 ` Krystian Kaniewski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1da196b-c3b0-4701-9cbf-bf357bfebfc8@gmail.com \
--to=krystianmkaniewski@gmail.com \
--cc=syzbot@kernel.org \
--cc=syzbot@lists.linux.dev \
--cc=syzkaller-upstream-moderation@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.