Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp477351yba; Wed, 15 May 2019 04:50:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxswcA0qcEeQA2O77qdRD5bIgNZEsjhPSzAqzKPKNlj41+7ZX+HGEh4Hj2DbbS+tVOlTfy5 X-Received: by 2002:aa7:8e04:: with SMTP id c4mr46290444pfr.48.1557921052187; Wed, 15 May 2019 04:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557921052; cv=none; d=google.com; s=arc-20160816; b=Xk//zYLX4cegeW1CzIdqiv9yvwdOfGo6u/yTbeUIb4S70maUSlifwfIi0NMdyR0XlO lwvuu8G0q4cHPdDN22BXHL8o5znBt9GUPSjQLOnKBUbhpEhIXCCE4C40bzx0lBVHdf3b j3bpXTtZKDytvlWvv1zfR+RuJCWGbvQMLfBKvJIKyL/utCjz6lZhKmpxnC3qUa9gBFOi Qvt3a6Pa/nts4IJU7NmMOiIxf3G/XXhAd/Dh2zI99hqxDHDN8EfnzZ6KnSh5nMOL5NTh ia8IrP5uCVnGfeohN5tXX3tSHxREwHVlHTFZnhovzCWxG7DI9nfefxFwKPirsYl7Ac8F oPHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V6374a+GAQHQduEVOpEMHMqf0J3TR/0jp5wSWGg4Z80=; b=qnIw0gp61QmYAOr6+E3uRKgWr4nqsWyzIEeRYtlpJVNOgrfUcTC+epjouycXSyOlfu x3LmvONnRUDpUrXazJhBu0Ot9BzMEAW7zXyaJHgo7jBtGN6hvXueIGWW7abvK4H1uhor 5HgNE7B9thy9Pr/fjBaGjSdz/tg1ARoGIQEt+sFTjzP3wnb5KiPZPRL340SHclPUtIev S9MefIjjxcz6+vLQ8/UccRQ0hVlhrI9uRxEZfvYiNOhs2cM7RHHlDUCxeK7ltpTg/+GN 8UH0XYTUVYnQp4mjdspQym5617jNtF7+F9dsGuGW+Yo5rFmUE7zcoK89GStyPMXeGm3s d6hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n8McB0IC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si1673316pgt.52.2019.05.15.04.50.37; Wed, 15 May 2019 04:50:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n8McB0IC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731723AbfEOLXv (ORCPT + 99 others); Wed, 15 May 2019 07:23:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:34296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731694AbfEOLXs (ORCPT ); Wed, 15 May 2019 07:23:48 -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 5A27920881; Wed, 15 May 2019 11:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919427; bh=JYkujlxxw32yNS0nlfdlOjicILURIxzUFUSHXFtYckM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n8McB0ICo8WY4Vqj/V4K0h2XaeVw6MDv4MVwXL/Qo7zxkR7cS9rlxU3JuJfRB0Fn+ 3WyQ1KhaIUG2/8RmeUKQX5OyTxcF+tu6gpurxiabAHRoSMfUR0st5thXPvBCwN5QNt 0tn+U6yIM6F2ngvn3CGI9qR82KtJLLHWu0rq3gKQ= 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 4.19 070/113] netfilter: nf_tables: use-after-free in dynamic operations Date: Wed, 15 May 2019 12:56:01 +0200 Message-Id: <20190515090658.842149354@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090652.640988966@linuxfoundation.org> References: <20190515090652.640988966@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 f272f9538c44a..ef7ff13a7b992 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -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, 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.20.1