All of lore.kernel.org
 help / color / mirror / Atom feed
From: xujiahao <xujiahao@cmss.chinamobile.com>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org,
	xujiahao <xujiahao@cmss.chinamobile.com>
Subject: Re: [PATCH nf] netfilter: xt_nat: allow IP_CT_RELATED_REPLY in DNAT targets
Date: Mon, 09 Nov 2026 12:35:26 +0800	[thread overview]
Message-ID: <20261109025392.reply@cmss.chinamobile.com> (raw)
In-Reply-To: <au2ClIl_C1RnEv_L@strlen.de>

Hi Florian,

You are right and my patch was wrong.  I am dropping the xt_nat change; the
check in xt_dnat_target_v2() should stay as it is.

I did reproduce the syzbot report in a netns: a reject rule makes
nf_send_reset() build the RST, which then goes ip_local_out() ->
nf_nat_ipv4_local_fn(), and the RST arrives with ctinfo IP_CT_RELATED_REPLY
(4).  nf_nat_inet_fn() therefore treats it as not initialized yet and runs the
nat chains for it, which is how xt_dnat_target_v2() is reached.  In my test
the conntrack was already confirmed, so nf_nat_setup_info() declined to
install a second mapping and the packet itself was not rewritten -- but the
nat chains should not be consulted for that packet at all.

Before I send a fix for nf_conntrack_attach(): it cannot tell an ICMP error
from a TCP RST on its own.  The icmp.c/icmpv6.c callers run inside a getfrag
callback, before the IP header is built, and the conntrack's L4 protocol is
the protocol of the original packet, which can well be TCP for an ICMP error.
So the packet type has to come from the call site.  Which shape do you prefer?

  a) nf_ct_attach(new, skb, bool tcp_rst) -- changes the exported symbol, or
  b) keep nf_ct_attach() as is and add a separate helper for the reject path?

Either way ICMP keeps IP_CT_RELATED/_REPLY, and only the RST built by
nf_reject_ipv4.c / nf_reject_ipv6.c would get IP_CT_ESTABLISHED/_REPLY.

Thanks,
xujiahao



  reply	other threads:[~2026-11-09  4:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  6:56 [PATCH nf] netfilter: xt_nat: allow IP_CT_RELATED_REPLY in DNAT targets xujiahao
2026-11-06  7:32 ` Florian Westphal
2026-11-09  4:35   ` xujiahao [this message]
2026-11-09 14:15     ` Florian Westphal
2026-11-10  2:18 ` [PATCH nf v2] netfilter: conntrack: attach generated TCP resets as ESTABLISHED xujiahao

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=20261109025392.reply@cmss.chinamobile.com \
    --to=xujiahao@cmss.chinamobile.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /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.