OSDN Git Service

netfilter: nft_set_rbtree: Detect partial overlap with start endpoint match
authorStefano Brivio <sbrivio@redhat.com>
Wed, 19 Aug 2020 21:59:15 +0000 (23:59 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 21 Aug 2020 15:37:36 +0000 (17:37 +0200)
commit0726763043dc10dd4c12481f050b1a5ef8f15410
tree1c9d36a5a6110587af1987c579c8a4593bbb077f
parent226a88de473e475cb9f993682a1c7d0c2b451ad8
netfilter: nft_set_rbtree: Detect partial overlap with start endpoint match

Getting creative with nft and omitting the interval_overlap()
check from the set_overlap() function, without omitting
set_overlap() altogether, led to the observation of a partial
overlap that wasn't detected, and would actually result in
replacement of the end element of an existing interval.

This is due to the fact that we'll return -EEXIST on a matching,
pre-existing start element, instead of -ENOTEMPTY, and the error
is cleared by API if NLM_F_EXCL is not given. At this point, we
can insert a matching start, and duplicate the end element as long
as we don't end up into other intervals.

For instance, inserting interval 0 - 2 with an existing 0 - 3
interval would result in a single 0 - 2 interval, and a dangling
'3' end element. This is because nft will proceed after inserting
the '0' start element as no error is reported, and no further
conflicting intervals are detected on insertion of the end element.

This needs a different approach as it's a local condition that can
be detected by looking for duplicate ends coming from left and
right, separately. Track those and directly report -ENOTEMPTY on
duplicated end elements for a matching start.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_rbtree.c