]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
netfilter: nft_compat: use-after-free when deleting targets
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Feb 2019 12:03:53 +0000 (13:03 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Feb 2019 17:14:54 +0000 (18:14 +0100)
Fetch pointer to module before target object is released.

Fixes: 29e3880109e3 ("netfilter: nf_tables: fix use-after-free when deleting compat expressions")
Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_compat.c

index fe64df848365b8a4ba137bbbcd3774887dbdc586..0a4bad55a8aaae1a205e63b967e767e45c249f8b 100644 (file)
@@ -315,6 +315,7 @@ nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
 {
        struct xt_target *target = expr->ops->data;
        void *info = nft_expr_priv(expr);
+       struct module *me = target->me;
        struct xt_tgdtor_param par;
 
        par.net = ctx->net;
@@ -325,7 +326,7 @@ nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
                par.target->destroy(&par);
 
        if (nft_xt_put(container_of(expr->ops, struct nft_xt, ops)))
-               module_put(target->me);
+               module_put(me);
 }
 
 static int nft_extension_dump_info(struct sk_buff *skb, int attr,