]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nft_set_rbtree: fix overlap expiration walk
authorFlorian Westphal <fw@strlen.de>
Thu, 20 Jul 2023 19:30:05 +0000 (21:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Aug 2023 08:22:36 +0000 (10:22 +0200)
commit50cbb9d195c197af671869c8cadce3bd483735a0
treedac5816f7e495988ac87bfaef1d6c741f1b63742
parentfeba294c454a51bb1e80dd2ff038e335f07ae481
netfilter: nft_set_rbtree: fix overlap expiration walk

[ Upstream commit f718863aca469a109895cb855e6b81fff4827d71 ]

The lazy gc on insert that should remove timed-out entries fails to release
the other half of the interval, if any.

Can be reproduced with tests/shell/testcases/sets/0044interval_overlap_0
in nftables.git and kmemleak enabled kernel.

Second bug is the use of rbe_prev vs. prev pointer.
If rbe_prev() returns NULL after at least one iteration, rbe_prev points
to element that is not an end interval, hence it should not be removed.

Lastly, check the genmask of the end interval if this is active in the
current generation.

Fixes: c9e6978e2725 ("netfilter: nft_set_rbtree: Switch to node list walk for overlap detection")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nft_set_rbtree.c