Skip to contentSkip to conversation

netfilter: nf_tables: underflow in nft_parse_u32_check()

PATCH Superseded Dan Carpenter 3 participants 4 messages Oct 12, 2016 – Oct 17, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: underflow in nft_parse_u32_check()

We don't want to allow negatives here.

Fixes 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')
net/netfilter/nf_tables_api.c +1 -1
index b70d3ea..dd55187 100644
@@ -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)
#1 lore raw

2016-10-12 14:08 GMT+08:00 Dan Carpenter <[email protected]>:

net/netfilter/nf_tables_api.c static int nf_tables_check_loops(const struct nft_ctx *ctx, · line 4423

Quoted 11 lines

We don't want to allow negatives here.

Fixes 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')
net/netfilter/nf_tables_api.c +0 -0
index b70d3ea..dd55187 100644
@@ -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:

net/netfilter/nf_tables_api.c static int nf_tables_check_loops(const struct nft_ctx *ctx, · line 4424

Quoted 1 line
net/netfilter/nf_tables_api.c +0 -0
 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)

net/netfilter/nf_tables_api.c static int nf_tables_check_loops(const struct nft_ctx *ctx, · line 4426

Quoted 3 lines
net/netfilter/nf_tables_api.c +1 -1
 {
-       int val;
+       uint val;
            u32 val;
Quoted 3 lines
net/netfilter/nf_tables_api.c +0 -0
        val = ntohl(nla_get_be32(attr));
        if (val > max)
#2 lore raw

PATCH v2 1/1 netfilter: nf_tables: underflow in nft_parse_u32_check()

We don't want to allow negatives here.

Fixes 36b701fae12a ('netfilter: nf_tables: validate maximum value of u32 netlink attributes')

---
v2: cosmetic change

net/netfilter/nf_tables_api.c +1 -1
index b70d3ea..dd55187 100644
@@ -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)

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#3 lore raw
Quoted 1 line · Dan Carpenter

We don't want to allow negatives here.

Applied, thanks.