netfilter: nft_set_rbtree: Drop spurious condition for overlap detection on insertion
authorStefano Brivio <sbrivio@redhat.com>
Wed, 1 Apr 2020 15:14:38 +0000 (17:14 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 5 Apr 2020 21:26:36 +0000 (23:26 +0200)
commit72239f2795fab9a58633bd0399698ff7581534a3
tree73571110e3295beee510f20861647fd329c727ad
parent0452800f6db4ed0a42ffb15867c0acfd68829f6a
netfilter: nft_set_rbtree: Drop spurious condition for overlap detection on insertion

Case a1. for overlap detection in __nft_rbtree_insert() is not a valid
one: start-after-start is not needed to detect any type of interval
overlap and it actually results in a false positive if, while
descending the tree, this is the only step we hit after starting from
the root.

This introduced a regression, as reported by Pablo, in Python tests
cases ip/ip.t and ip/numgen.t:

  ip/ip.t: ERROR: line 124: add rule ip test-ip4 input ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter: This rule should not have failed.
  ip/numgen.t: ERROR: line 7: add rule ip test-ip4 pre dnat to numgen inc mod 10 map { 0-5 : 192.168.10.100, 6-9 : 192.168.20.200}: This rule should not have failed.

Drop case a1. and renumber others, so that they are a bit clearer. In
order for these diagrams to be readily understandable, a bigger rework
is probably needed, such as an ASCII art of the actual rbtree (instead
of a flattened version).

Shell script test sets/0044interval_overlap_0 should cover all
possible cases for false negatives, so I consider that test case still
sufficient after this change.

v2: Fix comments for cases a3. and b3.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Fixes: 7c84d41416d8 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_rbtree.c