[patch] netfilter: nf_tables: underflow in nft_parse_u32_check()

Subsystems: netfilter, networking [general], the rest

STALE3612d

4 messages, 3 authors, 2016-10-17 · open the first message on its own page

[patch] netfilter: nf_tables: underflow in nft_parse_u32_check()

From: Dan Carpenter <hidden>
Date: 2016-10-12 06:08:11

We don't want to allow negatives here.

Fixes: 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')
Signed-off-by: Dan Carpenter <redacted>
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b70d3ea..dd55187 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4423,7 +4423,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
  */
 unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
 {
-	int val;
+	uint val;
 
 	val = ntohl(nla_get_be32(attr));
 	if (val > max)

Re: [patch] netfilter: nf_tables: underflow in nft_parse_u32_check()

From: Liping Zhang <hidden>
Date: 2016-10-12 07:27:19

2016-10-12 14:08 GMT+08:00 Dan Carpenter [off-list ref]:
quoted hunk
We don't want to allow negatives here.

Fixes: 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')
Signed-off-by: Dan Carpenter <redacted>
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b70d3ea..dd55187 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4423,7 +4423,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
  */
I think it's better if you can convert it to follows:
 unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
int nft_parse_u32_check(const struct nlattr *attr, u32 max, u32 *dest)
 {
-       int val;
+       uint val;
            u32 val;
        val = ntohl(nla_get_be32(attr));
        if (val > max)

[patch v2] netfilter: nf_tables: underflow in nft_parse_u32_check()

From: Dan Carpenter <hidden>
Date: 2016-10-12 09:15:54

We don't want to allow negatives here.

Fixes: 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')
Signed-off-by: Dan Carpenter <redacted>
---
v2: cosmetic change
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b70d3ea..dd55187 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4423,7 +4423,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
  */
 unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
 {
-	int val;
+	u32 val;
 
 	val = ntohl(nla_get_be32(attr));
 	if (val > max)

Re: [patch v2] netfilter: nf_tables: underflow in nft_parse_u32_check()

From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: 2016-10-17 15:40:09

On Wed, Oct 12, 2016 at 12:14:29PM +0300, Dan Carpenter wrote:
We don't want to allow negatives here.
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help