]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_set_rbtree: incorrect assumption on lower interval lookups
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 1 Mar 2017 17:15:11 +0000 (18:15 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 3 Mar 2017 12:48:32 +0000 (13:48 +0100)
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 <hanisch@wh2.tu-dresden.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_rbtree.c

index 71e8fb886a73b70489e635c63957cb9f8642ec5d..78dfbf9588b368107bdc385c7ef208a9abd3d297 100644 (file)
@@ -60,11 +60,10 @@ static bool nft_rbtree_lookup(const struct net *net, const struct nft_set *set,
                d = memcmp(this, key, set->klen);
                if (d < 0) {
                        parent = parent->rb_left;
-                       /* In case of adjacent ranges, we always see the high
-                        * part of the range in first place, before the low one.
-                        * So don't update interval if the keys are equal.
-                        */
-                       if (interval && nft_rbtree_equal(set, this, interval))
+                       if (interval &&
+                           nft_rbtree_equal(set, this, interval) &&
+                           nft_rbtree_interval_end(this) &&
+                           !nft_rbtree_interval_end(interval))
                                continue;
                        interval = rbe;
                } else if (d > 0)