mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
@ 2026-11-30  2:55 Hu Xinyao
  2026-11-30  2:59 ` netdev-bot+sinfo
  2026-11-30 11:45 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Hu Xinyao @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal
  Cc: Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Willem de Bruijn, Simon Horman, netfilter-devel,
	coreteam, netdev, linux-kernel

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.

Reset rbe_end to NULL when skipping an unexpired start element.

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
  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
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-30  2:59 UTC (permalink / raw)
  To: Hu Xinyao
  Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, netfilter-devel, coreteam,
	netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
  2026-11-30  2:59 ` netdev-bot+sinfo
@ 2026-11-30  3:09   ` Hu Xinyao
  0 siblings, 0 replies; 4+ messages in thread
From: Hu Xinyao @ 2026-11-30  3:09 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: Pablo Neira Ayuso, Florian Westphal, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Simon Horman, netfilter-devel, coreteam, netdev, linux-kernel

On Mon, 30 Nov 2026, netdev-bot+sinfo@kernel.org wrote:
>  - How the issue was discovered, e.g. hit in production, hit during
>    development, syzbot report, manual code inspection, LLM or static
>    analysis tool scan.
>
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by LLM and not proven at runtime). If it was triggered
>    please include the symptoms, like the stack trace or kernel messages.

1. Discovery: Found during a GLM-5.4-assisted code audit of
   net/netfilter/nft_set_rbtree.c and verified manually against v7.3.6
   and mainline.

2. Testing: Compile-tested only (CONFIG_NF_TABLES=y with -Werror); not
   triggered at runtime.

Thanks,
Hu Xinyao

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: nft_set_rbtree: clear stale rbe_end on unexpired start element
  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 11:45 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-30 11:45 UTC (permalink / raw)
  To: Hu Xinyao
  Cc: Florian Westphal, Phil Sutter, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	netfilter-devel, coreteam, netdev, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®