public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Pablo Neira Ayuso <pablo@netfilter.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 077/132] netfilter: nftables: add nft_parse_register_store() and use it
Date: Sun, 28 May 2023 20:10:16 +0100	[thread overview]
Message-ID: <20230528190835.892923424@linuxfoundation.org> (raw)
In-Reply-To: <20230528190833.565872088@linuxfoundation.org>

From: Pablo Neira Ayuso <pablo@netfilter.org>

[ 345023b0db315648ccc3c1a36aee88304a8b4d91 ]

This new function combines the netlink register attribute parser
and the store validation function.

This update requires to replace:

        enum nft_registers      dreg:8;

in many of the expression private areas otherwise compiler complains
with:

        error: cannot take address of bit-field ‘dreg’

when passing the register field as reference.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/netfilter/nf_tables.h      |  8 +++---
 include/net/netfilter/nf_tables_core.h |  4 +--
 include/net/netfilter/nft_fib.h        |  2 +-
 net/netfilter/nf_tables_api.c          | 34 ++++++++++++++++++++++----
 net/netfilter/nft_bitwise.c            |  8 +++---
 net/netfilter/nft_byteorder.c          |  8 +++---
 net/netfilter/nft_ct.c                 |  7 +++---
 net/netfilter/nft_exthdr.c             |  8 +++---
 net/netfilter/nft_fib.c                |  5 ++--
 net/netfilter/nft_hash.c               | 17 ++++++-------
 net/netfilter/nft_immediate.c          |  6 ++---
 net/netfilter/nft_lookup.c             |  8 +++---
 net/netfilter/nft_meta.c               |  7 +++---
 net/netfilter/nft_numgen.c             | 15 +++++-------
 net/netfilter/nft_osf.c                |  8 +++---
 net/netfilter/nft_payload.c            |  6 ++---
 net/netfilter/nft_rt.c                 |  7 +++---
 net/netfilter/nft_socket.c             |  7 +++---
 net/netfilter/nft_tunnel.c             |  8 +++---
 19 files changed, 92 insertions(+), 81 deletions(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index e7b1e241f6f6e..bf957156e9b76 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -195,10 +195,10 @@ unsigned int nft_parse_register(const struct nlattr *attr);
 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
 
 int nft_parse_register_load(const struct nlattr *attr, u8 *sreg, u32 len);
-int nft_validate_register_store(const struct nft_ctx *ctx,
-				enum nft_registers reg,
-				const struct nft_data *data,
-				enum nft_data_types type, unsigned int len);
+int nft_parse_register_store(const struct nft_ctx *ctx,
+			     const struct nlattr *attr, u8 *dreg,
+			     const struct nft_data *data,
+			     enum nft_data_types type, unsigned int len);
 
 /**
  *	struct nft_userdata - user defined data associated with an object
diff --git a/include/net/netfilter/nf_tables_core.h b/include/net/netfilter/nf_tables_core.h
index c81c12a825de4..6a3f76e012be3 100644
--- a/include/net/netfilter/nf_tables_core.h
+++ b/include/net/netfilter/nf_tables_core.h
@@ -28,7 +28,7 @@ struct nft_cmp_fast_expr {
 
 struct nft_immediate_expr {
 	struct nft_data		data;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 	u8			dlen;
 };
 
@@ -48,7 +48,7 @@ struct nft_payload {
 	enum nft_payload_bases	base:8;
 	u8			offset;
 	u8			len;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 };
 
 struct nft_payload_set {
diff --git a/include/net/netfilter/nft_fib.h b/include/net/netfilter/nft_fib.h
index a88f92737308d..1f87267395291 100644
--- a/include/net/netfilter/nft_fib.h
+++ b/include/net/netfilter/nft_fib.h
@@ -3,7 +3,7 @@
 #define _NFT_FIB_H_
 
 struct nft_fib {
-	enum nft_registers	dreg:8;
+	u8			dreg;
 	u8			result;
 	u32			flags;
 };
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 3b4cb6a9e85d5..b86d9c14cbd69 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3687,6 +3687,12 @@ static int nf_tables_delset(struct net *net, struct sock *nlsk,
 	return nft_delset(&ctx, set);
 }
 
+static int nft_validate_register_store(const struct nft_ctx *ctx,
+				       enum nft_registers reg,
+				       const struct nft_data *data,
+				       enum nft_data_types type,
+				       unsigned int len);
+
 static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx,
 					struct nft_set *set,
 					const struct nft_set_iter *iter,
@@ -7067,10 +7073,11 @@ EXPORT_SYMBOL_GPL(nft_parse_register_load);
  * 	A value of NULL for the data means that its runtime gathered
  * 	data.
  */
-int nft_validate_register_store(const struct nft_ctx *ctx,
-				enum nft_registers reg,
-				const struct nft_data *data,
-				enum nft_data_types type, unsigned int len)
+static int nft_validate_register_store(const struct nft_ctx *ctx,
+				       enum nft_registers reg,
+				       const struct nft_data *data,
+				       enum nft_data_types type,
+				       unsigned int len)
 {
 	int err;
 
@@ -7102,7 +7109,24 @@ int nft_validate_register_store(const struct nft_ctx *ctx,
 		return 0;
 	}
 }
-EXPORT_SYMBOL_GPL(nft_validate_register_store);
+
+int nft_parse_register_store(const struct nft_ctx *ctx,
+			     const struct nlattr *attr, u8 *dreg,
+			     const struct nft_data *data,
+			     enum nft_data_types type, unsigned int len)
+{
+	int err;
+	u32 reg;
+
+	reg = nft_parse_register(attr);
+	err = nft_validate_register_store(ctx, reg, data, type, len);
+	if (err < 0)
+		return err;
+
+	*dreg = reg;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(nft_parse_register_store);
 
 static const struct nla_policy nft_verdict_policy[NFTA_VERDICT_MAX + 1] = {
 	[NFTA_VERDICT_CODE]	= { .type = NLA_U32 },
diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
index 23a8a9d119876..c1055251ebdeb 100644
--- a/net/netfilter/nft_bitwise.c
+++ b/net/netfilter/nft_bitwise.c
@@ -19,7 +19,7 @@
 
 struct nft_bitwise {
 	u8			sreg;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 	u8			len;
 	struct nft_data		mask;
 	struct nft_data		xor;
@@ -73,9 +73,9 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
 	if (err < 0)
 		return err;
 
-	priv->dreg = nft_parse_register(tb[NFTA_BITWISE_DREG]);
-	err = nft_validate_register_store(ctx, priv->dreg, NULL,
-					  NFT_DATA_VALUE, priv->len);
+	err = nft_parse_register_store(ctx, tb[NFTA_BITWISE_DREG],
+				       &priv->dreg, NULL, NFT_DATA_VALUE,
+				       priv->len);
 	if (err < 0)
 		return err;
 
diff --git a/net/netfilter/nft_byteorder.c b/net/netfilter/nft_byteorder.c
index c81d618137ce8..5e1fbdd7b2846 100644
--- a/net/netfilter/nft_byteorder.c
+++ b/net/netfilter/nft_byteorder.c
@@ -20,7 +20,7 @@
 
 struct nft_byteorder {
 	u8			sreg;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 	enum nft_byteorder_ops	op:8;
 	u8			len;
 	u8			size;
@@ -144,9 +144,9 @@ static int nft_byteorder_init(const struct nft_ctx *ctx,
 	if (err < 0)
 		return err;
 
-	priv->dreg = nft_parse_register(tb[NFTA_BYTEORDER_DREG]);
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, priv->len);
+	return nft_parse_register_store(ctx, tb[NFTA_BYTEORDER_DREG],
+					&priv->dreg, NULL, NFT_DATA_VALUE,
+					priv->len);
 }
 
 static int nft_byteorder_dump(struct sk_buff *skb, const struct nft_expr *expr)
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 045e350ba03ea..f29f02805bcc0 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -29,7 +29,7 @@ struct nft_ct {
 	enum nft_ct_keys	key:8;
 	enum ip_conntrack_dir	dir:8;
 	union {
-		enum nft_registers	dreg:8;
+		u8		dreg;
 		u8		sreg;
 	};
 };
@@ -486,9 +486,8 @@ static int nft_ct_get_init(const struct nft_ctx *ctx,
 		}
 	}
 
-	priv->dreg = nft_parse_register(tb[NFTA_CT_DREG]);
-	err = nft_validate_register_store(ctx, priv->dreg, NULL,
-					  NFT_DATA_VALUE, len);
+	err = nft_parse_register_store(ctx, tb[NFTA_CT_DREG], &priv->dreg, NULL,
+				       NFT_DATA_VALUE, len);
 	if (err < 0)
 		return err;
 
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index 340520f10b686..8d0f14cd7cc3e 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -22,7 +22,7 @@ struct nft_exthdr {
 	u8			offset;
 	u8			len;
 	u8			op;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 	u8			sreg;
 	u8			flags;
 };
@@ -258,12 +258,12 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
 	priv->type   = nla_get_u8(tb[NFTA_EXTHDR_TYPE]);
 	priv->offset = offset;
 	priv->len    = len;
-	priv->dreg   = nft_parse_register(tb[NFTA_EXTHDR_DREG]);
 	priv->flags  = flags;
 	priv->op     = op;
 
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, priv->len);
+	return nft_parse_register_store(ctx, tb[NFTA_EXTHDR_DREG],
+					&priv->dreg, NULL, NFT_DATA_VALUE,
+					priv->len);
 }
 
 static int nft_exthdr_tcp_set_init(const struct nft_ctx *ctx,
diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
index 21df8cccea658..ce6891337304d 100644
--- a/net/netfilter/nft_fib.c
+++ b/net/netfilter/nft_fib.c
@@ -88,7 +88,6 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
 		return -EINVAL;
 
 	priv->result = ntohl(nla_get_be32(tb[NFTA_FIB_RESULT]));
-	priv->dreg = nft_parse_register(tb[NFTA_FIB_DREG]);
 
 	switch (priv->result) {
 	case NFT_FIB_RESULT_OIF:
@@ -108,8 +107,8 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
 		return -EINVAL;
 	}
 
-	err = nft_validate_register_store(ctx, priv->dreg, NULL,
-					  NFT_DATA_VALUE, len);
+	err = nft_parse_register_store(ctx, tb[NFTA_FIB_DREG], &priv->dreg,
+				       NULL, NFT_DATA_VALUE, len);
 	if (err < 0)
 		return err;
 
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index d08a14cfe56b7..513419aca9c66 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -19,7 +19,7 @@
 
 struct nft_jhash {
 	u8			sreg;
-	enum nft_registers      dreg:8;
+	u8			dreg;
 	u8			len;
 	bool			autogen_seed:1;
 	u32			modulus;
@@ -65,7 +65,7 @@ static void nft_jhash_map_eval(const struct nft_expr *expr,
 }
 
 struct nft_symhash {
-	enum nft_registers      dreg:8;
+	u8			dreg;
 	u32			modulus;
 	u32			offset;
 	struct nft_set		*map;
@@ -136,8 +136,6 @@ static int nft_jhash_init(const struct nft_ctx *ctx,
 	if (tb[NFTA_HASH_OFFSET])
 		priv->offset = ntohl(nla_get_be32(tb[NFTA_HASH_OFFSET]));
 
-	priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
-
 	err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len);
 	if (err < 0)
 		return err;
@@ -164,8 +162,8 @@ static int nft_jhash_init(const struct nft_ctx *ctx,
 		get_random_bytes(&priv->seed, sizeof(priv->seed));
 	}
 
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, sizeof(u32));
+	return nft_parse_register_store(ctx, tb[NFTA_HASH_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_jhash_map_init(const struct nft_ctx *ctx,
@@ -195,8 +193,6 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
 	if (tb[NFTA_HASH_OFFSET])
 		priv->offset = ntohl(nla_get_be32(tb[NFTA_HASH_OFFSET]));
 
-	priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
-
 	priv->modulus = ntohl(nla_get_be32(tb[NFTA_HASH_MODULUS]));
 	if (priv->modulus < 1)
 		return -ERANGE;
@@ -204,8 +200,9 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
 	if (priv->offset + priv->modulus - 1 < priv->offset)
 		return -EOVERFLOW;
 
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, sizeof(u32));
+	return nft_parse_register_store(ctx, tb[NFTA_HASH_DREG],
+					&priv->dreg, NULL, NFT_DATA_VALUE,
+					sizeof(u32));
 }
 
 static int nft_symhash_map_init(const struct nft_ctx *ctx,
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index 3f6d1d2a62818..af4e2a4bce93e 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.c
@@ -50,9 +50,9 @@ static int nft_immediate_init(const struct nft_ctx *ctx,
 
 	priv->dlen = desc.len;
 
-	priv->dreg = nft_parse_register(tb[NFTA_IMMEDIATE_DREG]);
-	err = nft_validate_register_store(ctx, priv->dreg, &priv->data,
-					  desc.type, desc.len);
+	err = nft_parse_register_store(ctx, tb[NFTA_IMMEDIATE_DREG],
+				       &priv->dreg, &priv->data, desc.type,
+				       desc.len);
 	if (err < 0)
 		goto err1;
 
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index 671f124d56b34..3c380fb326511 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -21,7 +21,7 @@
 struct nft_lookup {
 	struct nft_set			*set;
 	u8				sreg;
-	enum nft_registers		dreg:8;
+	u8				dreg;
 	bool				invert;
 	struct nft_set_binding		binding;
 };
@@ -100,9 +100,9 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
 		if (!(set->flags & NFT_SET_MAP))
 			return -EINVAL;
 
-		priv->dreg = nft_parse_register(tb[NFTA_LOOKUP_DREG]);
-		err = nft_validate_register_store(ctx, priv->dreg, NULL,
-						  set->dtype, set->dlen);
+		err = nft_parse_register_store(ctx, tb[NFTA_LOOKUP_DREG],
+					       &priv->dreg, NULL, set->dtype,
+					       set->dlen);
 		if (err < 0)
 			return err;
 	} else if (set->flags & NFT_SET_MAP)
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 7af90ed221113..061a29bd30661 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -30,7 +30,7 @@
 struct nft_meta {
 	enum nft_meta_keys	key:8;
 	union {
-		enum nft_registers	dreg:8;
+		u8		dreg;
 		u8		sreg;
 	};
 };
@@ -358,9 +358,8 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
 		return -EOPNOTSUPP;
 	}
 
-	priv->dreg = nft_parse_register(tb[NFTA_META_DREG]);
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, len);
+	return nft_parse_register_store(ctx, tb[NFTA_META_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_meta_get_validate(const struct nft_ctx *ctx,
diff --git a/net/netfilter/nft_numgen.c b/net/netfilter/nft_numgen.c
index 3cc1b3dc3c3cd..8ff82f17ecba9 100644
--- a/net/netfilter/nft_numgen.c
+++ b/net/netfilter/nft_numgen.c
@@ -20,7 +20,7 @@
 static DEFINE_PER_CPU(struct rnd_state, nft_numgen_prandom_state);
 
 struct nft_ng_inc {
-	enum nft_registers      dreg:8;
+	u8			dreg;
 	u32			modulus;
 	atomic_t		counter;
 	u32			offset;
@@ -70,11 +70,10 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
 	if (priv->offset + priv->modulus - 1 < priv->offset)
 		return -EOVERFLOW;
 
-	priv->dreg = nft_parse_register(tb[NFTA_NG_DREG]);
 	atomic_set(&priv->counter, priv->modulus - 1);
 
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, sizeof(u32));
+	return nft_parse_register_store(ctx, tb[NFTA_NG_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_ng_dump(struct sk_buff *skb, enum nft_registers dreg,
@@ -104,7 +103,7 @@ static int nft_ng_inc_dump(struct sk_buff *skb, const struct nft_expr *expr)
 }
 
 struct nft_ng_random {
-	enum nft_registers      dreg:8;
+	u8			dreg;
 	u32			modulus;
 	u32			offset;
 };
@@ -144,10 +143,8 @@ static int nft_ng_random_init(const struct nft_ctx *ctx,
 
 	prandom_init_once(&nft_numgen_prandom_state);
 
-	priv->dreg = nft_parse_register(tb[NFTA_NG_DREG]);
-
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, sizeof(u32));
+	return nft_parse_register_store(ctx, tb[NFTA_NG_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_ng_random_dump(struct sk_buff *skb, const struct nft_expr *expr)
diff --git a/net/netfilter/nft_osf.c b/net/netfilter/nft_osf.c
index 4fac2d9a4b885..af2ce7a8c5877 100644
--- a/net/netfilter/nft_osf.c
+++ b/net/netfilter/nft_osf.c
@@ -5,7 +5,7 @@
 #include <linux/netfilter/nfnetlink_osf.h>
 
 struct nft_osf {
-	enum nft_registers	dreg:8;
+	u8			dreg;
 };
 
 static const struct nla_policy nft_osf_policy[NFTA_OSF_MAX + 1] = {
@@ -55,9 +55,9 @@ static int nft_osf_init(const struct nft_ctx *ctx,
 	if (!tb[NFTA_OSF_DREG])
 		return -EINVAL;
 
-	priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]);
-	err = nft_validate_register_store(ctx, priv->dreg, NULL,
-					  NFT_DATA_VALUE, NFT_OSF_MAXGENRELEN);
+	err = nft_parse_register_store(ctx, tb[NFTA_OSF_DREG], &priv->dreg,
+				       NULL, NFT_DATA_VALUE,
+				       NFT_OSF_MAXGENRELEN);
 	if (err < 0)
 		return err;
 
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 6c5312fecac5c..77cfd5182784f 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -135,10 +135,10 @@ static int nft_payload_init(const struct nft_ctx *ctx,
 	priv->base   = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));
 	priv->offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
 	priv->len    = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
-	priv->dreg   = nft_parse_register(tb[NFTA_PAYLOAD_DREG]);
 
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, priv->len);
+	return nft_parse_register_store(ctx, tb[NFTA_PAYLOAD_DREG],
+					&priv->dreg, NULL, NFT_DATA_VALUE,
+					priv->len);
 }
 
 static int nft_payload_dump(struct sk_buff *skb, const struct nft_expr *expr)
diff --git a/net/netfilter/nft_rt.c b/net/netfilter/nft_rt.c
index 76dba9f6b6f62..edce109ef4b01 100644
--- a/net/netfilter/nft_rt.c
+++ b/net/netfilter/nft_rt.c
@@ -18,7 +18,7 @@
 
 struct nft_rt {
 	enum nft_rt_keys	key:8;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 };
 
 static u16 get_tcpmss(const struct nft_pktinfo *pkt, const struct dst_entry *skbdst)
@@ -134,9 +134,8 @@ static int nft_rt_get_init(const struct nft_ctx *ctx,
 		return -EOPNOTSUPP;
 	}
 
-	priv->dreg = nft_parse_register(tb[NFTA_RT_DREG]);
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, len);
+	return nft_parse_register_store(ctx, tb[NFTA_RT_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_rt_get_dump(struct sk_buff *skb,
diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c
index 4026ec38526f6..7e4f7063f4811 100644
--- a/net/netfilter/nft_socket.c
+++ b/net/netfilter/nft_socket.c
@@ -10,7 +10,7 @@
 struct nft_socket {
 	enum nft_socket_keys		key:8;
 	union {
-		enum nft_registers	dreg:8;
+		u8			dreg;
 	};
 };
 
@@ -119,9 +119,8 @@ static int nft_socket_init(const struct nft_ctx *ctx,
 		return -EOPNOTSUPP;
 	}
 
-	priv->dreg = nft_parse_register(tb[NFTA_SOCKET_DREG]);
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, len);
+	return nft_parse_register_store(ctx, tb[NFTA_SOCKET_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_socket_dump(struct sk_buff *skb,
diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
index 3fc55c81f16ac..ab69a34210a8d 100644
--- a/net/netfilter/nft_tunnel.c
+++ b/net/netfilter/nft_tunnel.c
@@ -14,7 +14,7 @@
 
 struct nft_tunnel {
 	enum nft_tunnel_keys	key:8;
-	enum nft_registers	dreg:8;
+	u8			dreg;
 };
 
 static void nft_tunnel_get_eval(const struct nft_expr *expr,
@@ -72,10 +72,8 @@ static int nft_tunnel_get_init(const struct nft_ctx *ctx,
 		return -EOPNOTSUPP;
 	}
 
-	priv->dreg = nft_parse_register(tb[NFTA_TUNNEL_DREG]);
-
-	return nft_validate_register_store(ctx, priv->dreg, NULL,
-					   NFT_DATA_VALUE, len);
+	return nft_parse_register_store(ctx, tb[NFTA_TUNNEL_DREG], &priv->dreg,
+					NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_tunnel_get_dump(struct sk_buff *skb,
-- 
2.39.2




  parent reply	other threads:[~2023-05-28 19:19 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-28 19:08 [PATCH 4.19 000/132] 4.19.284-rc1 review Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 001/132] net: Fix load-tearing on sk->sk_stamp in sock_recv_cmsgs() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 002/132] netlink: annotate accesses to nlk->cb_running Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 003/132] net: annotate sk->sk_err write from do_recvmmsg() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 004/132] tcp: reduce POLLOUT events caused by TCP_NOTSENT_LOWAT Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 005/132] tcp: return EPOLLOUT from tcp_poll only when notsent_bytes is half the limit Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 006/132] tcp: factor out __tcp_close() helper Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 007/132] tcp: add annotations around sk->sk_shutdown accesses Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 008/132] ipvlan:Fix out-of-bounds caused by unclear skb->cb Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 009/132] net: datagram: fix data-races in datagram_poll() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 010/132] af_unix: Fix a data race of sk->sk_receive_queue->qlen Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 011/132] af_unix: Fix data races around sk->sk_shutdown Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 012/132] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 013/132] drm/amd/display: Use DC_LOG_DC in the trasform pixel function Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 014/132] regmap: cache: Return error in cache sync operations for REGCACHE_NONE Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 015/132] memstick: r592: Fix UAF bug in r592_remove due to race condition Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 016/132] firmware: arm_sdei: Fix sleep from invalid context BUG Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 017/132] ACPI: EC: Fix oops when removing custom query handlers Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 018/132] drm/tegra: Avoid potential 32-bit integer overflow Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 019/132] ACPICA: Avoid undefined behavior: applying zero offset to null pointer Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 020/132] ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 021/132] wifi: brcmfmac: cfg80211: Pass the PMK in binary instead of hex Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 022/132] ext2: Check block size validity during mount Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 023/132] net: pasemi: Fix return type of pasemi_mac_start_tx() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 024/132] net: Catch invalid index in XPS mapping Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 025/132] lib: cpu_rmap: Avoid use after free on rmap->obj array entries Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 026/132] scsi: message: mptlan: Fix use after free bug in mptlan_remove() due to race condition Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 027/132] gfs2: Fix inode height consistency check Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 028/132] ext4: set goal start correctly in ext4_mb_normalize_request Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 029/132] ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 030/132] f2fs: fix to drop all dirty pages during umount() if cp_error is set Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 031/132] wifi: iwlwifi: dvm: Fix memcpy: detected field-spanning write backtrace Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 032/132] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 033/132] staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 034/132] HID: logitech-hidpp: Dont use the USB serial for USB devices Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 035/132] HID: logitech-hidpp: Reconcile USB and Unifying serials Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 036/132] spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 037/132] HID: wacom: generic: Set battery quirk only when we see battery data Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 038/132] usb: typec: tcpm: fix multiple times discover svids error Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 039/132] serial: 8250: Reinit port->pm on port specific driver unbind Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 040/132] mcb-pci: Reallocate memory region to avoid memory overlapping Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 041/132] sched: Fix KCSAN noinstr violation Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 042/132] recordmcount: Fix memory leaks in the uwrite function Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 043/132] clk: tegra20: fix gcc-7 constant overflow warning Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 044/132] Input: xpad - add constants for GIP interface numbers Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 045/132] phy: st: miphy28lp: use _poll_timeout functions for waits Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 046/132] mfd: dln2: Fix memory leak in dln2_probe() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 047/132] btrfs: replace calls to btrfs_find_free_ino with btrfs_find_free_objectid Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 048/132] btrfs: fix space cache inconsistency after error loading it from disk Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 049/132] cpupower: Make TSC read per CPU for Mperf monitor Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 050/132] af_key: Reject optional tunnel/BEET mode templates in outbound policies Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 051/132] net: fec: Better handle pm_runtime_get() failing in .remove() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 052/132] vsock: avoid to close connected socket after the timeout Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 053/132] drivers: provide devm_platform_ioremap_resource() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 054/132] serial: arc_uart: fix of_iomap leak in `arc_serial_probe` Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 055/132] ip6_gre: Fix skb_under_panic in __gre6_xmit() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 056/132] ip6_gre: Make o_seqno start from 0 in native mode Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 057/132] ip_gre, ip6_gre: Fix race condition on o_seqno in collect_md mode Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 058/132] erspan: get the proto with the md version for collect_md Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 059/132] media: netup_unidvb: fix use-after-free at del_timer() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.19 060/132] drm/exynos: fix g2d_open/close helper function definitions Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 061/132] net: nsh: Use correct mac_offset to unwind gso skb in nsh_gso_segment() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 062/132] net: bcmgenet: Remove phy_stop() from bcmgenet_netif_stop() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 063/132] net: bcmgenet: Restore phy_stop() depending upon suspend/close Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 064/132] cassini: Fix a memory leak in the error handling path of cas_init_one() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 065/132] igb: fix bit_shift to be in [1..8] range Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 066/132] vlan: fix a potential uninit-value in vlan_dev_hard_start_xmit() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 067/132] usb-storage: fix deadlock when a scsi command timeouts more than once Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 068/132] usb: typec: altmodes/displayport: fix pin_assignment_show Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 069/132] ALSA: hda: Fix Oops by 9.1 surround channel names Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 070/132] ALSA: hda: Add NVIDIA codec IDs a3 through a7 to patch table Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 071/132] statfs: enforce statfs[64] structure initialization Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 072/132] serial: Add support for Advantech PCI-1611U card Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 073/132] ceph: force updating the msg pointer in non-split case Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 074/132] tpm/tpm_tis: Disable interrupts for more Lenovo devices Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 075/132] nilfs2: fix use-after-free bug of nilfs_root in nilfs_evict_inode() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 076/132] netfilter: nftables: add nft_parse_register_load() and use it Greg Kroah-Hartman
2023-05-28 19:10 ` Greg Kroah-Hartman [this message]
2023-05-28 19:10 ` [PATCH 4.19 078/132] netfilter: nftables: statify nft_parse_register() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 079/132] netfilter: nf_tables: validate registers coming from userspace Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 080/132] netfilter: nf_tables: add nft_setelem_parse_key() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 081/132] netfilter: nf_tables: allow up to 64 bytes in the set element data area Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 082/132] netfilter: nf_tables: stricter validation of element data Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 083/132] netfilter: nf_tables: validate NFTA_SET_ELEM_OBJREF based on NFT_SET_OBJECT flag Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 084/132] netfilter: nf_tables: do not allow RULE_ID to refer to another chain Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 085/132] HID: wacom: Force pen out of prox if no events have been received in a while Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 086/132] Add Acer Aspire Ethos 8951G model quirk Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 087/132] ALSA: hda/realtek - More constifications Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 088/132] ALSA: hda/realtek - Add Headset Mic supported for HP cPC Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 089/132] ALSA: hda/realtek - Enable headset mic of Acer X2660G with ALC662 Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 090/132] ALSA: hda/realtek - Enable the headset of Acer N50-600 " Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 091/132] ALSA: hda/realtek - The front Mic on a HP machine doesnt work Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 092/132] ALSA: hda/realtek: Fix the mic type detection issue for ASUS G551JW Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 093/132] ALSA: hda/realtek - Add headset Mic support for Lenovo ALC897 platform Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 094/132] ALSA: hda/realtek - ALC897 headset MIC no sound Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 095/132] ALSA: hda/realtek: Add a quirk for HP EliteDesk 805 Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 096/132] lib/string_helpers: Introduce string_upper() and string_lower() helpers Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 097/132] usb: gadget: u_ether: Convert prints to device prints Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 098/132] usb: gadget: u_ether: Fix host MAC address case Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 099/132] vc_screen: rewrite vcs_size to accept vc, not inode Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 100/132] vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 101/132] s390/qdio: get rid of register asm Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 102/132] s390/qdio: fix do_sqbs() inline assembly constraint Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 103/132] spi: spi-fsl-spi: automatically adapt bits-per-word in cpu mode Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 104/132] spi: fsl-spi: Re-organise transfer bits_per_word adaptation Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 105/132] spi: fsl-cpm: Use 16 bit mode for large transfers with even size Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 106/132] ALSA: hda/ca0132: add quirk for EVGA X299 DARK Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 107/132] m68k: Move signal frame following exception on 68020/030 Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 108/132] parisc: Allow to reboot machine after system halt Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 109/132] btrfs: use nofs when cleaning up aborted transactions Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 110/132] x86/mm: Avoid incomplete Global INVLPG flushes Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 111/132] selftests/memfd: Fix unknown type name build failure Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 112/132] parisc: Fix flush_dcache_page() for usage from irq context Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 113/132] ALSA: hda/realtek - Fixed one of HP ALC671 platform Headset Mic supported Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 114/132] ALSA: hda/realtek - Fix inverted bass GPIO pin on Acer 8951G Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 115/132] udplite: Fix NULL pointer dereference in __sk_mem_raise_allocated() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 116/132] USB: core: Add routines for endpoint checks in old drivers Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 117/132] USB: sisusbvga: Add endpoint checks Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 118/132] media: radio-shark: " Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 119/132] net: fix skb leak in __skb_tstamp_tx() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.19 120/132] bpf: Fix mask generation for 32-bit narrow loads of 64-bit fields Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 121/132] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 122/132] power: supply: leds: Fix blink to LED on transition Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 123/132] power: supply: bq27xxx: Fix bq27xxx_battery_update() race condition Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 124/132] power: supply: bq27xxx: Fix I2C IRQ race on remove Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 125/132] power: supply: bq27xxx: Fix poll_interval handling and races " Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 126/132] power: supply: sbs-charger: Fix INHIBITED bit for Status reg Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 127/132] coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet() Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 128/132] xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 129/132] x86/show_trace_log_lvl: Ensure stack pointer is aligned, again Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 130/132] ASoC: Intel: Skylake: Fix declaration of enum skl_ch_cfg Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 131/132] forcedeth: Fix an error handling path in nv_probe() Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.19 132/132] 3c589_cs: Fix an error handling path in tc589_probe() Greg Kroah-Hartman
2023-05-29 13:48 ` [PATCH 4.19 000/132] 4.19.284-rc1 review Guenter Roeck
2023-05-29 13:49   ` Guenter Roeck
2023-05-29 14:28     ` Naresh Kamboju
2023-05-29 15:20       ` Guenter Roeck
2023-05-29 15:38         ` Greg Kroah-Hartman
2023-05-30  9:19 ` Jon Hunter

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=20230528190835.892923424@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=pablo@netfilter.org \
    --cc=patches@lists.linux.dev \
    --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