From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org
Subject: [PATCH net 03/11] netfilter: nf_tables: Fix dereference of null pointer flow
Date: Wed, 7 Jul 2021 18:18:36 +0200 [thread overview]
Message-ID: <20210707161844.20827-4-pablo@netfilter.org> (raw)
In-Reply-To: <20210707161844.20827-1-pablo@netfilter.org>
From: Colin Ian King <colin.king@canonical.com>
In the case where chain->flags & NFT_CHAIN_HW_OFFLOAD is false then
nft_flow_rule_create is not called and flow is NULL. The subsequent
error handling execution via label err_destroy_flow_rule will lead
to a null pointer dereference on flow when calling nft_flow_rule_destroy.
Since the error path to err_destroy_flow_rule has to cater for null
and non-null flows, only call nft_flow_rule_destroy if flow is non-null
to fix this issue.
Addresses-Coverity: ("Explicity null dereference")
Fixes: 3c5e44622011 ("netfilter: nf_tables: memleak in hw offload abort path")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 390d4466567f..de182d1f7c4e 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3446,7 +3446,8 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
return 0;
err_destroy_flow_rule:
- nft_flow_rule_destroy(flow);
+ if (flow)
+ nft_flow_rule_destroy(flow);
err_release_rule:
nf_tables_rule_release(&ctx, rule);
err_release_expr:
--
2.20.1
next prev parent reply other threads:[~2021-07-07 16:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 16:18 [PATCH net 00/11] Netfilter fixes for net Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 01/11] selftest: netfilter: add test case for unreplied tcp connections Pablo Neira Ayuso
2021-07-07 21:10 ` patchwork-bot+netdevbpf
2021-07-07 16:18 ` [PATCH net 02/11] netfilter: conntrack: do not renew entry stuck in tcp SYN_SENT state Pablo Neira Ayuso
2021-07-07 16:18 ` Pablo Neira Ayuso [this message]
2021-07-07 16:18 ` [PATCH net 04/11] netfilter: conntrack: nf_ct_gre_keymap_flush() removal Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 05/11] netfilter: ctnetlink: suspicious RCU usage in ctnetlink_dump_helpinfo Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 06/11] netfilter: conntrack: improve RST handling when tuple is re-used Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 07/11] netfilter: conntrack: add new sysctl to disable RST check Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 08/11] netfilter: conntrack: Mark access for KCSAN Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 09/11] netfilter: nft_last: honor NFTA_LAST_SET on restoration Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 10/11] netfilter: nft_last: incorrect arithmetics when restoring last used Pablo Neira Ayuso
2021-07-07 16:18 ` [PATCH net 11/11] netfilter: uapi: refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210707161844.20827-4-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).