From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, fw@strlen.de
Subject: [PATCH net 4/6] netfilter: nf_tables: bail out on mismatching dynset and set expressions
Date: Wed, 6 Dec 2023 19:03:55 +0100 [thread overview]
Message-ID: <20231206180357.959930-5-pablo@netfilter.org> (raw)
In-Reply-To: <20231206180357.959930-1-pablo@netfilter.org>
If dynset expressions provided by userspace is larger than the declared
set expressions, then bail out.
Fixes: 48b0ae046ee9 ("netfilter: nftables: netlink support for several set element expressions")
Reported-by: Xingyuan Mo <hdthky0@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_dynset.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
index b18a79039125..c09dba57354c 100644
--- a/net/netfilter/nft_dynset.c
+++ b/net/netfilter/nft_dynset.c
@@ -280,10 +280,15 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
priv->expr_array[i] = dynset_expr;
priv->num_exprs++;
- if (set->num_exprs &&
- dynset_expr->ops != set->exprs[i]->ops) {
- err = -EOPNOTSUPP;
- goto err_expr_free;
+ if (set->num_exprs) {
+ if (i >= set->num_exprs) {
+ err = -EINVAL;
+ goto err_expr_free;
+ }
+ if (dynset_expr->ops != set->exprs[i]->ops) {
+ err = -EOPNOTSUPP;
+ goto err_expr_free;
+ }
}
i++;
}
--
2.30.2
next prev parent reply other threads:[~2023-12-06 18:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 18:03 [PATCH net 0/6] Netfilter fixes for net Pablo Neira Ayuso
2023-12-06 18:03 ` [PATCH net 1/6] netfilter: bpf: fix bad registration on nf_defrag Pablo Neira Ayuso
2023-12-07 18:00 ` patchwork-bot+netdevbpf
2023-12-06 18:03 ` [PATCH net 2/6] netfilter: nft_set_pipapo: skip inactive elements during set walk Pablo Neira Ayuso
2023-12-06 18:03 ` [PATCH net 3/6] netfilter: nf_tables: fix 'exist' matching on bigendian arches Pablo Neira Ayuso
2023-12-06 18:03 ` Pablo Neira Ayuso [this message]
2023-12-06 18:03 ` [PATCH net 5/6] netfilter: nf_tables: validate family when identifying table via handle Pablo Neira Ayuso
2023-12-06 18:03 ` [PATCH net 6/6] netfilter: xt_owner: Fix for unsafe access of sk->sk_socket 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=20231206180357.959930-5-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
/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).