mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
netfilter: nft_dynset: restore set element counter when failing to update
commit05907f10e2
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:22fe54d5fe
("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>
This commit is contained in:
parent
85d55a187c
commit
47fbca31ba
1 changed files with 2 additions and 0 deletions
|
@ -127,6 +127,7 @@ static bool nft_rhash_update(struct nft_set *set, const u32 *key,
|
|||
/* Another cpu may race to insert the element with the same key */
|
||||
if (prev) {
|
||||
nft_set_elem_destroy(set, he, true);
|
||||
atomic_dec(&set->nelems);
|
||||
he = prev;
|
||||
}
|
||||
|
||||
|
@ -136,6 +137,7 @@ static bool nft_rhash_update(struct nft_set *set, const u32 *key,
|
|||
|
||||
err2:
|
||||
nft_set_elem_destroy(set, he, true);
|
||||
atomic_dec(&set->nelems);
|
||||
err1:
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue