]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nf_tables: possible module reference underflow in error path
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 9 Aug 2022 15:23:52 +0000 (17:23 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 10 Aug 2022 15:06:05 +0000 (17:06 +0200)
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: 03abf76334ec ("netfilter: nftables: generalize set expressions support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index ac549c5b88c2dd03a1bab2d31dd8796ab8d1dbb3..989c9782ecc347db3917a59d63be09aecc218cc2 100644 (file)
@@ -5601,7 +5601,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;