[RHEL7,COMMIT] ms/netfilter: nft_compat: use-after-free when deleting targets

Submitted by Konstantin Khorenko on Nov. 25, 2019, 8:03 a.m.

Details

Message ID 201911250803.xAP83Ccv001357@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Nov. 25, 2019, 8:03 a.m.
The commit is pushed to "branch-rh7-3.10.0-1062.4.2.vz7.116.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.4.2.vz7.116.4
------>
commit b3a036ad32e44796ff754c6f9e35874e2304bbe4
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Wed Feb 13 13:03:53 2019 +0100

    ms/netfilter: nft_compat: use-after-free when deleting targets
    
    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>
    
    Backported in the scope of https://jira.sw.ru/browse/PSBM-99656
    
    (cherry picked from commit 753c111f655e38bbd52fc01321266633f022ebe2)
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 net/netfilter/nft_compat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index be17f603b90d..4a875378c40d 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -265,6 +265,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;
@@ -275,7 +276,7 @@  nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
 		par.target->destroy(&par);
 
 	nft_xt_put(container_of(expr->ops, struct nft_xt, ops));
-	module_put(target->me);
+	module_put(me);
 }
 
 static int nft_target_dump(struct sk_buff *skb, const struct nft_expr *expr)