[Devel] [PATCH RH7 2/4] ms/netfilter: nft_set_rbtree: handle element re-addition after deletion
Vasily Averin
vvs at virtuozzo.com
Fri Dec 18 13:24:57 MSK 2020
From: Pablo Neira Ayuso <pablo at netfilter.org>
The existing code selects no next branch to be inspected when
re-inserting an inactive element into the rb-tree, looping endlessly.
This patch restricts the check for active elements to the EEXIST case
only.
Fixes: e701001e7cbe ("netfilter: nft_rbtree: allow adjacent intervals with dynamic updates")
Reported-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
Tested-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
(cherry-picked from commit d2df92e98a34a5619dadd29c6291113c009181e7)
VvS: minor context changes
https://jira.sw.ru/browse/PSBM-121318
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
net/netfilter/nft_rbtree.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/net/netfilter/nft_rbtree.c b/net/netfilter/nft_rbtree.c
index ea06aa9..f9cfcf7 100644
--- a/net/netfilter/nft_rbtree.c
+++ b/net/netfilter/nft_rbtree.c
@@ -117,15 +117,16 @@ static int __nft_rbtree_insert(const struct nft_set *set,
else if (d > 0)
p = &parent->rb_right;
else {
- if (nft_set_elem_active(&rbe->ext, genmask)) {
- if (nft_rbtree_interval_end(rbe) &&
- !nft_rbtree_interval_end(new))
- p = &parent->rb_left;
- else if (!nft_rbtree_interval_end(rbe) &&
- nft_rbtree_interval_end(new))
- p = &parent->rb_right;
- else
- return -EEXIST;
+ if (nft_rbtree_interval_end(rbe) &&
+ !nft_rbtree_interval_end(new))
+ p = &parent->rb_left;
+ else if (!nft_rbtree_interval_end(rbe) &&
+ nft_rbtree_interval_end(new))
+ p = &parent->rb_right;
+ else if (nft_set_elem_active(&rbe->ext, genmask)) {
+ return -EEXIST;
+ } else {
+ p = &parent->rb_left;
}
}
}
--
1.8.3.1
More information about the Devel
mailing list