]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
netfilter: nf_tables: unconditionally bump set->nelems before insertion
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 2 Mar 2026 22:12:37 +0000 (23:12 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 5 Mar 2026 12:22:37 +0000 (13:22 +0100)
commitdef602e498a4f951da95c95b1b8ce8ae68aa733a
tree809a1dc4f74d343d74018ee45b27e45650bfd482
parentb824c3e16c1904bf80df489e293d1e3cbf98896d
netfilter: nf_tables: unconditionally bump set->nelems before insertion

In case that the set is full, a new element gets published then removed
without waiting for the RCU grace period, while RCU reader can be
walking over it already.

To address this issue, add the element transaction even if set is full,
but toggle the set_full flag to report -ENFILE so the abort path safely
unwinds the set to its previous state.

As for element updates, decrement set->nelems to restore it.

A simpler fix is to call synchronize_rcu() in the error path.
However, with a large batch adding elements to already maxed-out set,
this could cause noticeable slowdown of such batches.

Fixes: 35d0ac9070ef ("netfilter: nf_tables: fix set->nelems counting with no NLM_F_EXCL")
Reported-by: Inseo An <y0un9sa@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_tables_api.c