All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Minghao Zhang <zhangmh25@mails.tsinghua.edu.cn>
Cc: netfilter-devel@vger.kernel.org, pablo@netfilter.org,
	Jianjun Chen <jianjun@tsinghua.edu.cn>
Subject: Re: [PATCH nf-next] netfilter: conntrack: tcp: use UNACK timeout for non-closing RST packets
Date: Wed, 29 Jul 2026 17:09:03 +0200	[thread overview]
Message-ID: <amoXj6UGRW8SQXBT@strlen.de> (raw)
In-Reply-To: <20260729142802.3572612-1-zhangmh25@mails.tsinghua.edu.cn>

Minghao Zhang <zhangmh25@mails.tsinghua.edu.cn> wrote:
> Commit be0502a3f2e9 ("netfilter: conntrack: tcp: only close if RST
> matches exact sequence") keeps an established conntrack entry in
> ESTABLISHED when an in-window RST does not match the expected sequence
> number exactly, so the endpoint can validate the RST with a challenge
> ACK.
> 
> The timeout selection nevertheless uses the CLOSE timeout for every RST
> packet.  The bug is that timeout selection is based on the packet type,
> not on the state transition result: even when RST validation keeps
> new_state in ESTABLISHED, the timeout is still forced to
> TCP_CONNTRACK_CLOSE.
> 
> Linux TCP independently rate limits challenge ACKs per socket.  A second
> non-exact RST can therefore arrive after the first challenge ACK has
> restored the timeout but before the rate limit expires.  The second RST
> lowers the timeout to 10 seconds again while the endpoint suppresses the
> second challenge ACK, allowing the conntrack entry to expire while both
> TCP endpoints remain established.
> 
> Using the ESTABLISHED timeout for non-exact RSTs would avoid this short
> expiration window, but it could also retain stale entries for the
> five-day default because conntrack cannot reliably match the endpoint's
> exact TCP state.
> 
> Use the UNACK timeout for RST packets that do not move the conntrack
> entry to TCP_CONNTRACK_CLOSE.  Exact-match RSTs and accepted RST packet
> trains still use the CLOSE timeout because their state transition result
> is CLOSE.  This avoids the exploitable 10-second expiration window for
> non-exact RSTs while preserving the short timeout for RSTs that
> conntrack accepts as closing the flow.

Hmm.

>  		timeout = timeouts[TCP_CONNTRACK_RETRANS];
> -	else if (unlikely(index == TCP_RST_SET))
> +	else if (unlikely(index == TCP_RST_SET &&
> +			  new_state == TCP_CONNTRACK_CLOSE))
>  		timeout = timeouts[TCP_CONNTRACK_CLOSE];

Is this needed?  If new state is TCP_CONNTRACK_CLOSE, the existing
else branch will:
        else
                timeout = timeouts[new_state];

> +	else if (unlikely(index == TCP_RST_SET))
> +		timeout = timeouts[TCP_CONNTRACK_UNACK];

AFAICS this is enough:
-       else if (unlikely(index == TCP_RST_SET))
-               timeout = timeouts[TCP_CONNTRACK_CLOSE];
+       else if (unlikely(index == TCP_RST_SET && new_state != TCP_CONNTRACK_ESTABLISHED))
+               timeout = timeouts[TCP_CONNTRACK_UNACK];

Could you test this?  Thanks!

  reply	other threads:[~2026-07-29 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 14:28 [PATCH nf-next] netfilter: conntrack: tcp: use UNACK timeout for non-closing RST packets Minghao Zhang
2026-07-29 15:09 ` Florian Westphal [this message]
2026-07-29 15:51   ` zhangmh25
2026-07-29 15:46 ` [PATCH v2 " Minghao Zhang

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=amoXj6UGRW8SQXBT@strlen.de \
    --to=fw@strlen.de \
    --cc=jianjun@tsinghua.edu.cn \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=zhangmh25@mails.tsinghua.edu.cn \
    /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.