Skip to content

Commit 704c025

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: nft_set_pipapo: fix range overlap detection
[ Upstream commit 7711f4b ] set->klen has to be used, not sizeof(). The latter only compares a single register but a full check of the entire key is needed. Example: table ip t { map s { typeof iifname . ip saddr : verdict flags interval } } nft add element t s '{ "lo" . 10.0.0.0/24 : drop }' # no error, expected nft add element t s '{ "lo" . 10.0.0.0/24 : drop }' # no error, expected nft add element t s '{ "lo" . 10.0.0.0/8 : drop }' # bug: no error The 3rd 'add element' should be rejected via -ENOTEMPTY, not -EEXIST, so userspace / nft can report an error to the user. The latter is only correct for the 2nd case (re-add of existing element). As-is, userspace is told that the command was successful, but no elements were added. After this patch, 3rd command gives: Error: Could not process rule: File exists add element t s { "lo" . 127.0.0.0/8 . "lo" : drop } ^^^^^^^^^^^^^^^^^^^^^^^^^ Fixes: 0eb4b5e ("netfilter: nft_set_pipapo: Separate partial and complete overlap cases on insertion") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 499c0db commit 704c025

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,8 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
13171317
else
13181318
dup_end = dup_key;
13191319

1320-
if (!memcmp(start, dup_key->data, sizeof(*dup_key->data)) &&
1321-
!memcmp(end, dup_end->data, sizeof(*dup_end->data))) {
1320+
if (!memcmp(start, dup_key->data, set->klen) &&
1321+
!memcmp(end, dup_end->data, set->klen)) {
13221322
*elem_priv = &dup->priv;
13231323
return -EEXIST;
13241324
}

0 commit comments

Comments
 (0)