netfilter: nf_tables: unbind non-anonymous set if rule construction fails
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: nf_tables: unbind non-anonymous set if rule construction fails
Otherwise a dangling reference to a rule object that is gone remains in the set binding list.
--- net/netfilter/nf_tables_api.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_tables_api.c +2 -0
@@ -5343,6 +5343,8 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,nft_set_trans_unbind (ctx, set);if (nft_set_is_anonymous (set))nft_deactivate_next (ctx->net, set); +else +list_del_rcu (&binding->list); set->use--;break ;
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nf_tables: fix underflow in chain reference counter
Set element addition error path decrements reference counter on chains
twice: once on element release and again via nft_data_release().
Then, d6b478666ffa ("netfilter: nf_tables: fix underflow in object reference counter") incorrectly fixed this by removing the stateful object reference count decrement.
Restore the stateful object decrement as in b91d90368837 ("netfilter:nf_tables: fix leaking object reference count") and let nft_data_release() decrement the chain reference counter, so this is done only once.
--- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +3 -1
@@ -6771,7 +6771,9 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, err_element_clash:kfree (trans); err_elem_free: -nft_set_elem_destroy (set, elem.priv, true); +nf_tables_set_elem_destroy (ctx, set, elem.priv); +if (obj) + obj->use--; err_parse_data:if (nla[NFTA_SET_ELEM_DATA ] !=NULL )nft_data_release (&elem.data.val, desc.type);
Signature · 1 line
2.30.2