Skip to content

Commit

Permalink
netfilter: nft_set_rbtree: handle element re-addition after deletion
Browse files Browse the repository at this point in the history
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: e701001 ("netfilter: nft_rbtree: allow adjacent intervals with dynamic updates")
Reported-by: Wolfgang Bumiller <[email protected]>
Tested-by: Wolfgang Bumiller <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
ummakynes committed May 23, 2017
1 parent f3c0eb0 commit d2df92e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions net/netfilter/nft_set_rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ static int __nft_rbtree_insert(const struct net *net, 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 {
*ext = &rbe->ext;
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)) {
*ext = &rbe->ext;
return -EEXIST;
} else {
p = &parent->rb_left;
}
}
}
Expand Down

0 comments on commit d2df92e

Please sign in to comment.