All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Hu Xinyao <huxinyao@kylinsec.com.cn>
Cc: Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
Date: Mon, 30 Nov 2026 12:45:55 +0100	[thread overview]
Message-ID: <aw1h8-QfSQYIifUt@chamomile> (raw)
In-Reply-To: <54EEAAE000DA2911+1796007358.199103-1-huxinyao@kylinsec.com.cn>

On Mon, Nov 30, 2026 at 11:55:58AM +0900, Hu Xinyao wrote:
> nft_rbtree_gc_scan() iterates the rbtree from highest to lowest key and
> records each active NFT_SET_ELEM_INTERVAL_END node in rbe_end so it can
> be removed alongside its matching start element.
> 
> When the start element is not expired, the loop skips it without
> clearing rbe_end. If a subsequent lower-valued expired start element is
> not preceded by its own active end node (for instance, after its end
> marker was separately removed via NFT_MSG_DELSETELEM), gc_scan()
> deactivates and erases the stale rbe_end belonging to the live interval.

I guess you are dealing with a random set with intervals with
incremental updates on left,right sides of the interval.

> Reset rbe_end to NULL when skipping an unexpired start element.

We have received patches like this already with scenarios that we
don't consider valid (ie. userspace nft does support).
 
> Fixes: 8d8540c4f5e0 ("netfilter: nft_set_rbtree: add timeout support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hu Xinyao <huxinyao@kylinsec.com.cn>
> ---
>  net/netfilter/nft_set_rbtree.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
> index 9d68589..2f7887e 100644
> --- a/net/netfilter/nft_set_rbtree.c
> +++ b/net/netfilter/nft_set_rbtree.c
> @@ -911,8 +911,10 @@ static void nft_rbtree_gc_scan(struct nft_set *set)
>  			rbe_end = rbe;
>  			continue;
>  		}
> -		if (!__nft_set_elem_expired(&rbe->ext, tstamp))
> +		if (!__nft_set_elem_expired(&rbe->ext, tstamp)) {
> +			rbe_end = NULL;
>  			continue;
> +		}
>  
>  		/* end element needs to be removed first, it has
>  		 * no timeout extension.
> -- 
> 2.43.0
> 

  parent reply	other threads:[~2026-11-30 11:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  2:55 [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element Hu Xinyao
2026-11-30  2:59 ` netdev-bot+sinfo
2026-11-30  3:09   ` Hu Xinyao
2026-11-30 11:45 ` Pablo Neira Ayuso [this message]
2026-12-01  2:58 ` netdev-bot+sashiko

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=aw1h8-QfSQYIifUt@chamomile \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=huxinyao@kylinsec.com.cn \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=phil@nwl.cc \
    --cc=willemb@google.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.