netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 2/6] netfilter: ipset: Fix forceadd evaluation path
Date: Wed, 26 Feb 2020 23:54:38 +0100	[thread overview]
Message-ID: <20200226225442.9598-3-pablo@netfilter.org> (raw)
In-Reply-To: <20200226225442.9598-1-pablo@netfilter.org>

From: Jozsef Kadlecsik <kadlec@netfilter.org>

When the forceadd option is enabled, the hash:* types should find and replace
the first entry in the bucket with the new one if there are no reuseable
(deleted or timed out) entries. However, the position index was just not set
to zero and remained the invalid -1 if there were no reuseable entries.

Reported-by: syzbot+6a86565c74ebe30aea18@syzkaller.appspotmail.com
Fixes: 23c42a403a9c ("netfilter: ipset: Introduction of new commands and protocol version 7")
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
---
 net/netfilter/ipset/ip_set_hash_gen.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 71e93eac0831..e52d7b7597a0 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -931,6 +931,8 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
 		}
 	}
 	if (reuse || forceadd) {
+		if (j == -1)
+			j = 0;
 		data = ahash_data(n, j, set->dsize);
 		if (!deleted) {
 #ifdef IP_SET_HASH_WITH_NETS
-- 
2.11.0


  parent reply	other threads:[~2020-02-26 22:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 22:54 [PATCH 0/6] Netfilter fixes for net Pablo Neira Ayuso
2020-02-26 22:54 ` [PATCH 1/6] netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports Pablo Neira Ayuso
2020-02-26 22:54 ` Pablo Neira Ayuso [this message]
2020-02-26 22:54 ` [PATCH 3/6] selftests: nft_concat_range: Move option for 'list ruleset' before command Pablo Neira Ayuso
2020-02-26 22:54 ` [PATCH 4/6] nft_set_pipapo: Actually fetch key data in nft_pipapo_remove() Pablo Neira Ayuso
2020-02-26 22:54 ` [PATCH 5/6] selftests: nft_concat_range: Add test for reported add/flush/add issue Pablo Neira Ayuso
2020-02-26 22:54 ` [PATCH 6/6] netfilter: xt_hashlimit: unregister proc file before releasing mutex Pablo Neira Ayuso
2020-02-27  0:32 ` [PATCH 0/6] Netfilter fixes for net David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226225442.9598-3-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).