From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 909D2C10F12 for ; Mon, 15 Apr 2019 19:21:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E61B20651 for ; Mon, 15 Apr 2019 19:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555356065; bh=Px4SXH4Qu7IsscEnsCciKQ9BkMvPTyG3sP1QYiqjNto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zMmqZHyq6PtYT0k+pxB30b6rxn5D4HFpelMOq3OEW6nnhquKIKGfIj+IGfkonHv7t XxUmBSvrlNocbSdM503XnTFeeedYSbVxz2TH81Dlci1XhzH/Hzopgm6iuJEW6NEfsw iaUtJ2RQE0mW8Hl1JqEBLsXcYqwh13zW8KKh40jg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729753AbfDOTU7 (ORCPT ); Mon, 15 Apr 2019 15:20:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:45374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730765AbfDOTJh (ORCPT ); Mon, 15 Apr 2019 15:09:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3333218A1; Mon, 15 Apr 2019 19:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355377; bh=Px4SXH4Qu7IsscEnsCciKQ9BkMvPTyG3sP1QYiqjNto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HgLpohPl1zsV+k3MHzx0n8pzG1f4+O4OKyhHki7G84ZQf9XCrg6x81B9F+7xNEzPN W/iOokA0IdmJyfRs8RpF51k5ThrWZ4ZM3AnwEQsh5ksiKcEeMjM/8SwKWc3I++Gdn3 KzpK9RFrB/njxD+ef8GAqz2IjISevPpMZiZxFTRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.0 004/117] netfilter: nf_tables: use-after-free in dynamic operations Date: Mon, 15 Apr 2019 20:59:34 +0200 Message-Id: <20190415183745.109568968@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183744.887851196@linuxfoundation.org> References: <20190415183744.887851196@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 3f3a390dbd59d236f62cff8e8b20355ef7069e3d ] 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: b8e204006340 ("netfilter: nft_compat: use .release_ops and remove list of extension") Reported-by: Dan Carpenter Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index dc3670f2860e..f20b904873c6 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2119,9 +2119,11 @@ static int nf_tables_newexpr(const struct nft_ctx *ctx, static void nf_tables_expr_destroy(const struct nft_ctx *ctx, struct nft_expr *expr) { + const struct nft_expr_type *type = expr->ops->type; + if (expr->ops->destroy) 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, -- 2.19.1