]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nft_dynset: restore set element counter when failing to update
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 21 Jun 2022 12:01:41 +0000 (14:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Jul 2022 15:31:17 +0000 (17:31 +0200)
commit47fbca31ba3c032dfd0aa97d7b32c1313a618741
tree1a5602ac23609d75e3517a804832b3c9f7120f47
parent85d55a187ca0405a5fcfded2ef464a733d45ee95
netfilter: nft_dynset: restore set element counter when failing to update

commit 05907f10e235680cc7fb196810e4ad3215d5e648 upstream.

This patch fixes a race condition.

nft_rhash_update() might fail for two reasons:

- Element already exists in the hashtable.
- Another packet won race to insert an entry in the hashtable.

In both cases, new() has already bumped the counter via atomic_add_unless(),
therefore, decrement the set element counter.

Fixes: 22fe54d5fefc ("netfilter: nf_tables: add support for dynamic set updates")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nft_set_hash.c