]> git.baikalelectronics.ru Git - kernel.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:36:50 +0000 (17:36 +0200)
commitc4b88973f4ccf7447ccfca78462ac5489d1d6612
tree53983eabce50f6583ed28539f0a8dabf2f5792a3
parent4bdb86e1fd0feb13c80ed0dc1dd9fc24475df034
netfilter: nft_dynset: restore set element counter when failing to update

commit 8e25c562a250bef37cef10011264d8c07c29d230 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: e907265f4d6d ("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