🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24587

Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element

#24587
From: Pablo Neira Ayuso
Date: Mon, 30 Nov 2026 11:45
46 lines
10154 bytes
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
> 
Technical Details
Message-ID: <aw1h8-QfSQYIifUt@chamomile>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374143-linux-kernel-netdev=dewy.ru
References: <54EEAAE000DA2911+1796007358.199103-1-huxinyao@kylinsec.com.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374143-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on
 unexpired start element
Date: Mon, 30 Nov 2026 12:45:55 +0100
Organization: Usenet Network
Message-ID: <aw1h8-QfSQYIifUt@chamomile>
References: <54EEAAE000DA2911+1796007358.199103-1-huxinyao@kylinsec.com.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="1416187"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+nxmmh4N1oDETpZyg8NwENiyS0s= sha256:kFzpiYbqMyvYZmY7CxBZ5jsE0tnZXTmfIuAM0mRisaU=
	sha1:43DH9axVCyW0D5ezkDPE1GD3Urc= sha256:ciXtvd56Wh7BW0XaJVOM8dn3+vNp72vn0+vjrc76hzI=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 41ED4125FDE; Mon, 30 Nov 2026 14:46:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=netfilter.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7HKWO8iHc4Wk;
	Mon, 30 Nov 2026 14:46:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374143-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C8102125FD9; Mon, 30 Nov 2026 14:46:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 3F5DD2B234; Mon, 30 Nov 2026 11:46:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1796039175;
	b=clPAG6SycvwsCK80Hy3patzCxwSu7iWtFEp8xcBje8PPDpsVWmNsyPqZp8wV7yAl2Oeo
	 zINVhJmBau+8KdoBzCI2cHEG2dC35J4S7KUDWgPuGhQxndCu9aY83M3szUVQ16l9wOG8G
	 9+n4arTkNqVjujBZSYLxbrw9AdKjzmYX0hGfDQ2xXnGNw6nI2zPEWKreUg78/5krwmRLm
	 2X8T2scRkAo2miMWry5qj8c38WfjcFzOTW6wzrh5uX6vQCoUWNf1r3Bbz6SL/7m+GGhpK
	 bg/ZZ+1aMdAvEVPb7Vd9MZqv2KN/MNJQPxWWPJ+8d1/cUc/SxaVatDk5pljZUaFfwUA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796039175;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=kWun4m0NxbcEWU5u+BLUOfyC+uc8kzhLWu+87SB07YM=;
	b=gnDC+dzUvWtfAVeqswzCEWKy/AZLnI9/CgphtEpHYPC1aaravf/PZZvgfmZmIFBoDeem
	 BDZC3C4GsCKO3LdqslwlODO9XbbjAilXMkKkTEkITzF7eN6t2krdgxR8DQhjyMUkr+6J1
	 2KVbZNuofe8uJba8+f56ilZWNKZFD5SciZubfCtld5WU0YVdSwpS27d7UMBNBYmO+ttPp
	 sY7ekQl9l+qadCR1wnogFAA3ODlvSbAsOwLjrmPAknCAl8qX5G/MexLAEAPiplukmwryS
	 Pxn98/63DbgSmHb2ahkcz2UyxWhT/QXf/mS7lSFunWJXojp1jk0ZKt2Mw+fT3cWrsKg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=d+r0w+Mu;
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 16797606A32C;
	Mon, 30 Nov 2026 11:46:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=d+r0w+Mu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796039169;
	b=RrJlUB6+12I9IZ/ma/e96bqtDSS0tgbKomeN8dfAyQDHhBt23P/KLf30Ddh0zBmTz5Ww
	 cyKjMSZOI9j4o6UGojyWfDTvZCbE4B+2AmQpC2x33LTrQQ4S/KbSzTyS87TWEsqOfs1Fk
	 7MXW+LSD8bKzS8RQUfRgSwahWPRoqw1ozyVULzpjnFPF+FPtcbKE4QIyNF18oCGzEcx20
	 5f1ywoCotkJvbfeDOa7tOabfXWLJ8/BHA1sjsnY0QxiWlwu7QWG1uf3M1VaJe6doxfwqH
	 Ok51YE53INh5NRMMhrWeIf8yxmUWApePmTSo7FMmxo4wpQGPjmKIRdO48NqE1iXKNbg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796039169;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To:X-Spam-Status:X-Spam-Checker-Version;
	bh=kWun4m0NxbcEWU5u+BLUOfyC+uc8kzhLWu+87SB07YM=;
	b=VgzmOZsiSYAh5ZBHXim+XYDRap0N0RsH5upERTEolfhIXJWF4kzQ7g0shGeS0NOPyEea
	 deT5m6Ym/FHx5jkDNnGNzboancQjxYl9qmeKPCAeNAdJtjf+mUIGuRqDHy+X8G+W6LWpR
	 mxMSyUE79iw9FaIvOuFtZ2r0Ek+aWWflqfu9Pa0YhdTqRUYbePhRSJOBJc8QvjnCex+DY
	 Z3uSuUFxWKJFO5K+/0/H77CbSehKFVurn6u5VuuJdn3/yaNEiixovGpvpdas0SKreVz/X
	 lS4zYeZCvodeBkqD4omW6ODc8JNZWgdi/CgQw9sKDNewEJbbc8P281X7fHaIzF3ocUA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=d+r0w+Mu;
	arc=none smtp.remote-ip=217.70.190.124
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 160CD606A31C;
	Mon, 30 Nov 2026 11:46:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 160CD606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;
	s=2025; t=1796039159;
	bh=kWun4m0NxbcEWU5u+BLUOfyC+uc8kzhLWu+87SB07YM=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
	b=d+r0w+MuaqZki7cPFvfl7/1hi0AhHMlbIPJWIfHChDVzIbASz2QLOI0i5jgtHzGJt
	 sSFwEr8GLt56Y44TRKnKbYcE+OWqvz/UM7eeDquVAiFOcsAg8L+uxg+NPtGVWsR6MR
	 4i/JeMwMIQxaz4vzTNEwOEhGX3pqTjkFHfG/E1TCTYUJ7huddJvG4bJhX1oGBylxCd
	 db4hR+oSOxTvlkf9zUwff+znixr0GX2JRHzXadLzH6/GVLnWM2e+rRYABq4GSnTinh
	 Kqmk+HzJmTIRqZB6Q6BN9DO8ig03jRPg0W6ED+sPpOaK+azovni0d9H+WTcs3SfsYU
	 IZr2rkdtH2ylw==
X-Received: from netfilter.org (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with UTF8SMTPSA id 063816005E;
	Mon, 30 Nov 2026 12:45:59 +0100 (CET)
X-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
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <54EEAAE000DA2911+1796007358.199103-1-huxinyao@kylinsec.com.cn>