From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 06/10] netfilter: nf_tables: prevent shift wrap in nft_chain_parse_hook()
Date: Mon, 22 Apr 2019 22:47:57 +0200 [thread overview]
Message-ID: <20190422204801.26321-7-pablo@netfilter.org> (raw)
In-Reply-To: <20190422204801.26321-1-pablo@netfilter.org>
From: Dan Carpenter <dan.carpenter@oracle.com>
I believe that "hook->num" can be up to UINT_MAX. Shifting more than
31 bits would is undefined in C but in practice it would lead to shift
wrapping. That would lead to an array overflow in nf_tables_addchain():
ops->hook = hook.type->hooks[ops->hooknum];
Fixes: fe19c04ca137 ("netfilter: nf_tables: remove nhooks field from struct nft_af_info")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index ef7772e976cc..1606eaa5ae0d 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1545,7 +1545,7 @@ static int nft_chain_parse_hook(struct net *net,
if (IS_ERR(type))
return PTR_ERR(type);
}
- if (!(type->hook_mask & (1 << hook->num)))
+ if (hook->num > NF_MAX_HOOKS || !(type->hook_mask & (1 << hook->num)))
return -EOPNOTSUPP;
if (type->type == NFT_CHAIN_T_NAT &&
--
2.11.0
next prev parent reply other threads:[~2019-04-22 20:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-22 20:47 [PATCH 00/10] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 01/10] selftests: netfilter: check icmp pkttoobig errors are set as related Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 02/10] netfilter: conntrack: don't set related state for different outer address Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 03/10] netfilter: conntrack: initialize ct->timeout Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 04/10] ipvs: do not schedule icmp errors from tunnels Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 05/10] netfilter: ctnetlink: don't use conntrack/expect object addresses as id Pablo Neira Ayuso
2019-04-22 20:47 ` Pablo Neira Ayuso [this message]
2019-04-22 20:47 ` [PATCH 07/10] netfilter: nat: fix icmp id randomization Pablo Neira Ayuso
2019-04-22 20:47 ` [PATCH 08/10] netfilter: ebtables: CONFIG_COMPAT: drop a bogus WARN_ON Pablo Neira Ayuso
2019-04-22 20:48 ` [PATCH 09/10] netfilter: never get/set skb->tstamp Pablo Neira Ayuso
2019-04-22 20:48 ` [PATCH 10/10] netfilter: fix nf_l4proto_log_invalid to log invalid packets Pablo Neira Ayuso
2019-04-23 4:25 ` [PATCH 00/10] Netfilter/IPVS fixes for net David Miller
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=20190422204801.26321-7-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--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).