public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, stable@vger.kernel.org, sashal@kernel.org
Subject: [PATCH -stable,4.14 07/11] netfilter: nf_tables: stricter validation of element data
Date: Sat, 27 May 2023 18:08:07 +0200	[thread overview]
Message-ID: <20230527160811.67779-8-pablo@netfilter.org> (raw)
In-Reply-To: <20230527160811.67779-1-pablo@netfilter.org>

[ 7e6bc1f6cabcd30aba0b11219d8e01b952eacbb6 ]

Make sure element data type and length do not mismatch the one specified
by the set declaration.

Fixes: 7d7402642eaf ("netfilter: nf_tables: variable sized set element keys / data")
Reported-by: Hugues ANGUELKOV <hanguelkov@randorisec.fr>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 1cd49af7d375..9caaac459ca9 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3959,13 +3959,20 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set,
 				  struct nft_data *data,
 				  struct nlattr *attr)
 {
+	u32 dtype;
 	int err;
 
 	err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr);
 	if (err < 0)
 		return err;
 
-	if (desc->type != NFT_DATA_VERDICT && desc->len != set->dlen) {
+	if (set->dtype == NFT_DATA_VERDICT)
+		dtype = NFT_DATA_VERDICT;
+	else
+		dtype = NFT_DATA_VALUE;
+
+	if (dtype != desc->type ||
+	    set->dlen != desc->len) {
 		nft_data_release(data, desc->type);
 		return -EINVAL;
 	}
-- 
2.30.2


  parent reply	other threads:[~2023-05-27 15:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27 16:08 [PATCH -stable,4.14 00/11] more stable fixes for 4.14 Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 01/11] netfilter: nftables: add nft_parse_register_load() and use it Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 02/11] netfilter: nftables: add nft_parse_register_store() " Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 03/11] netfilter: nftables: statify nft_parse_register() Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 04/11] netfilter: nf_tables: validate registers coming from userspace Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 05/11] netfilter: nf_tables: add nft_setelem_parse_key() Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 06/11] netfilter: nf_tables: allow up to 64 bytes in the set element data area Pablo Neira Ayuso
2023-05-27 16:08 ` Pablo Neira Ayuso [this message]
2023-05-27 16:08 ` [PATCH -stable,4.14 08/11] netfilter: nft_dynset: do not reject set updates with NFT_SET_EVAL Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 09/11] netfilter: nf_tables: do not allow RULE_ID to refer to another chain Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 10/11] netfilter: nf_tables: do not allow SET_ID to refer to another table Pablo Neira Ayuso
2023-05-27 16:08 ` [PATCH -stable,4.14 11/11] netfilter: nf_tables: fix register ordering Pablo Neira Ayuso
2023-05-28  7:36 ` [PATCH -stable,4.14 00/11] more stable fixes for 4.14 Greg KH

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=20230527160811.67779-8-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@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