Skip to content

Commit f912135

Browse files
committed
netfilter: nft_set_rbtree: incorrect assumption on lower interval lookups
In case of adjacent ranges, we may indeed see either the high part of the range in first place or the low part of it. Remove this incorrect assumption, let's make sure we annotate the low part of the interval in case of we have adjacent interva intervals so we hit a matching in lookups. Reported-by: Simon Hanisch <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent da2f27e commit f912135

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

net/netfilter/nft_set_rbtree.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ static bool nft_rbtree_lookup(const struct net *net, const struct nft_set *set,
6060
d = memcmp(this, key, set->klen);
6161
if (d < 0) {
6262
parent = parent->rb_left;
63-
/* In case of adjacent ranges, we always see the high
64-
* part of the range in first place, before the low one.
65-
* So don't update interval if the keys are equal.
66-
*/
67-
if (interval && nft_rbtree_equal(set, this, interval))
63+
if (interval &&
64+
nft_rbtree_equal(set, this, interval) &&
65+
nft_rbtree_interval_end(this) &&
66+
!nft_rbtree_interval_end(interval))
6867
continue;
6968
interval = rbe;
7069
} else if (d > 0)

0 commit comments

Comments
 (0)