Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8561265ybl; Thu, 16 Jan 2020 19:38:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzCEiAZd8UfyRJbInTBy1UugavHylpmVIJlSnN3etOj5i8d/1Ahjdy5LBMAiy0z8qvF8wS+ X-Received: by 2002:aca:31c8:: with SMTP id x191mr1906425oix.25.1579232292271; Thu, 16 Jan 2020 19:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579232292; cv=none; d=google.com; s=arc-20160816; b=qSNqhCzep2BTdl/3DNrtnPHdwW7/Nby51rbXT+ZHb3gdpmpNjD88GdMsGsnL7CXhtY Z5nFc3781g9M0NYjCNJ1CSegFyi+2pRxCZpzYeqkg5sZvrqihjjCSKt0T2uhKmdMApK0 dY+SKwSbpMfq4MRkZK902qGXK8wC93sXScxPeammzJy7CYmmoJEFrCgKIQTZtRgJ3/jL q52B/tgLKnbnyVhsvkPugXSqrFfglimnn7WXhLlEduVxNJ/g0DZrQ0bEDZGpvi4DlFrI hiRVVo2zOCk+D/YpYlnkcfhKzRE4TycV0XepUJR7Zgh8dN3QLgCUVvz6Q1zlZmDoVoFl G0aw== 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=mw6QGMP/KBp1GRBy33tUDtQJpiukuVCR1gCkLWG1QvA=; b=dr9/K5RVBe8W5uZJPk+zEa6fikCxoDl6eT+eftGzisLMfRL4XfMAq1YUvwgp9bZbhm HLa5C2tEDX5yQDsSxk1v7TqlxIaWP1n6pcf8Tp40I6uqVdipZfsCxqdjMFzdA0Q4jP5q prX/rUkYjxYcW+jndU4Lce6Oha7DA/K0+a1/CFaRnbqUrzvFjMSGS9M/95UH2wfyfBRh exRGGYbazIXorPs1bUk8sh5d8cf5MZ8M9OFGDDyxEyhaI1s3AGN4YpRLb9Dm5f4yIvcW W776cDc/RKPzrfACsfS0YHvCL2i1wwqph7UAdwQaD8QJ3KfsB0Rzn5uDhv5DunVqDBTa cDmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Q66Qc8a/"; 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 b1si12687073oiy.9.2020.01.16.19.38.00; Thu, 16 Jan 2020 19:38:12 -0800 (PST) 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="Q66Qc8a/"; 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 S2392058AbgAPXqi (ORCPT + 99 others); Thu, 16 Jan 2020 18:46:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:49374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729624AbgAPXVs (ORCPT ); Thu, 16 Jan 2020 18:21:48 -0500 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 D078A2077C; Thu, 16 Jan 2020 23:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579216908; bh=4QuQBs/y2wtwL6SKyn0ignYxYeQE9C0+uY2gTmS+OEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q66Qc8a/TKR8xnb1geFdOgRfdZnhD6EpmBZZjD3mbQzVGJ6ZpBvWU2GTKp9nOClNd Mbz62iVC5LiBEmJAUy8Krd7KcTX7AzKFnTKuVFHlTldaCPm03r1HhuTicrsEtxJbkx f+ZnuVksLxMWzNpxH+BZkJ7WvusklB+cktpxeO7o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.4 053/203] netfilter: nf_tables_offload: release flow_rule on error from commit path Date: Fri, 17 Jan 2020 00:16:10 +0100 Message-Id: <20200116231748.608901770@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@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 From: Pablo Neira Ayuso commit 23403cd8898dbc9808d3eb2f63bc1db8a340b751 upstream. If hardware offload commit path fails, release all flow_rule objects. Fixes: c9626a2cbdb2 ("netfilter: nf_tables: add hardware offload support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_offload.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) --- a/net/netfilter/nf_tables_offload.c +++ b/net/netfilter/nf_tables_offload.c @@ -358,14 +358,14 @@ int nft_flow_rule_offload_commit(struct continue; if (trans->ctx.flags & NLM_F_REPLACE || - !(trans->ctx.flags & NLM_F_APPEND)) - return -EOPNOTSUPP; - + !(trans->ctx.flags & NLM_F_APPEND)) { + err = -EOPNOTSUPP; + break; + } err = nft_flow_offload_rule(trans->ctx.chain, nft_trans_rule(trans), nft_trans_flow_rule(trans), FLOW_CLS_REPLACE); - nft_flow_rule_destroy(nft_trans_flow_rule(trans)); break; case NFT_MSG_DELRULE: if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD)) @@ -379,7 +379,23 @@ int nft_flow_rule_offload_commit(struct } if (err) - return err; + break; + } + + list_for_each_entry(trans, &net->nft.commit_list, list) { + if (trans->ctx.family != NFPROTO_NETDEV) + continue; + + switch (trans->msg_type) { + case NFT_MSG_NEWRULE: + if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD)) + continue; + + nft_flow_rule_destroy(nft_trans_flow_rule(trans)); + break; + default: + break; + } } return err;