Commit 5014aa93 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by Greg Kroah-Hartman

netfilter: nf_tables: use-after-free in dynamic operations

[ Upstream commit 3f3a390d ]

Smatch reports:

       net/netfilter/nf_tables_api.c:2167 nf_tables_expr_destroy()
        error: dereferencing freed memory 'expr->ops'

net/netfilter/nf_tables_api.c
    2162 static void nf_tables_expr_destroy(const struct nft_ctx *ctx,
    2163                                   struct nft_expr *expr)
    2164 {
    2165        if (expr->ops->destroy)
    2166                expr->ops->destroy(ctx, expr);
                                                ^^^^
--> 2167        module_put(expr->ops->type->owner);
                           ^^^^^^^^^
    2168 }

Smatch says there are three functions which free expr->ops.

Fixes: b8e20400 ("netfilter: nft_compat: use .release_ops and remove list of extension")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
parent 9965da06
...@@ -2113,9 +2113,11 @@ static int nf_tables_newexpr(const struct nft_ctx *ctx, ...@@ -2113,9 +2113,11 @@ static int nf_tables_newexpr(const struct nft_ctx *ctx,
static void nf_tables_expr_destroy(const struct nft_ctx *ctx, static void nf_tables_expr_destroy(const struct nft_ctx *ctx,
struct nft_expr *expr) struct nft_expr *expr)
{ {
const struct nft_expr_type *type = expr->ops->type;
if (expr->ops->destroy) if (expr->ops->destroy)
expr->ops->destroy(ctx, expr); expr->ops->destroy(ctx, expr);
module_put(expr->ops->type->owner); module_put(type->owner);
} }
struct nft_expr *nft_expr_init(const struct nft_ctx *ctx, struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment