Skip to contentSkip to conversation

netfilter: nf_tables: possible module reference underflow in error path

PATCH New Pablo Neira Ayuso 1 participant 2 messages Aug 9, 2022

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: possible module reference underflow in error path

dst->ops is set on when nft_expr_clone() fails, but module refcount has not been bumped yet, therefore nft_expr_destroy() leads to module reference underflow.

Fixes 8cfd9b0f8515 ("netfilter: nftables: generalize set expressions support")
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 75d9e386fb2c..56f0b477999f 100644
@@ -5593,7 +5593,7 @@ int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,
 
 		err = nft_expr_clone(expr, set->exprs[i]);
 		if (err < 0) {
-			nft_expr_destroy(ctx, expr);
+			kfree(expr);
 			goto err_expr;
 		}
 		expr_array[i] = expr;
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH 1/1 netfilter: nf_tables: really skip inactive sets when allocating name

While looping to build the bitmap of used anonymous set names, check the current set in the iteration, instead of the one that is being created.

Fixes 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets")
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 56f0b477999f..708ce3c1deb1 100644
@@ -3899,7 +3899,7 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
 		list_for_each_entry(i, &ctx->table->sets, list) {
 			int tmp;
 
-			if (!nft_is_active_next(ctx->net, set))
+			if (!nft_is_active_next(ctx->net, i))
 				continue;
 			if (!sscanf(i->name, name, &tmp))
 				continue;
Signature · 1 line
2.30.2