diff mbox series

[net,1/2] netfilter: nf_tables: stricter validation of element data

Message ID 20220702191029.238563-2-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series [net,1/2] netfilter: nf_tables: stricter validation of element data | expand

Commit Message

Pablo Neira Ayuso July 2, 2022, 7:10 p.m. UTC
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(-)

Comments

patchwork-bot+netdevbpf@kernel.org July 3, 2022, 11:30 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (master)
by Pablo Neira Ayuso <pablo@netfilter.org>:

On Sat,  2 Jul 2022 21:10:27 +0200 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net,1/2] netfilter: nf_tables: stricter validation of element data
    https://git.kernel.org/netdev/net/c/7e6bc1f6cabc
  - [net,2/2] netfilter: nft_set_pipapo: release elements in clone from abort path
    https://git.kernel.org/netdev/net/c/9827a0e6e23b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 51144fc66889..d6b59beab3a9 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -5213,13 +5213,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;
 	}