Skip to contentSkip to conversation

netfilter: nft_connlimit: fix nft clone() functions

PATCH In review Dan Carpenter 2 participants 5 messages Jan 11, 2022 – Jan 12, 2022

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

PATCH v2 1/1 netfilter: nft_connlimit: fix nft clone() functions

These NULL checks are reversed so the clone() can never succeed.

Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")

---
v2: fix a couple similar bugs

 net/netfilter/nft_connlimit.c | 2 +-
 net/netfilter/nft_last.c      | 2 +-
 net/netfilter/nft_quota.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nft_connlimit.c +1 -1
index 58dcafe8bf79..7d00a1452b1d 100644
@@ -206,7 +206,7 @@ static int nft_connlimit_clone(struct nft_expr *dst, const struct nft_expr *src)
 	struct nft_connlimit *priv_src = nft_expr_priv(src);
 
 	priv_dst->list = kmalloc(sizeof(*priv_dst->list), GFP_ATOMIC);
-	if (priv_dst->list)
+	if (!priv_dst->list)
 		return -ENOMEM;
 
 	nf_conncount_list_init(priv_dst->list);
net/netfilter/nft_last.c +1 -1
index 5ee33d0ccd4e..4f745a409d34 100644
@@ -106,7 +106,7 @@ static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src)
 	struct nft_last_priv *priv_dst = nft_expr_priv(dst);
 
 	priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC);
-	if (priv_dst->last)
+	if (!priv_dst->last)
 		return -ENOMEM;
 
 	return 0;
net/netfilter/nft_quota.c +1 -1
index 0484aef74273..f394a0b562f6 100644
@@ -237,7 +237,7 @@ static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src)
 	struct nft_quota *priv_dst = nft_expr_priv(dst);
 
 	priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC);
-	if (priv_dst->consumed)
+	if (!priv_dst->consumed)
 		return -ENOMEM;
 
 	atomic64_set(priv_dst->consumed, 0);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Dan Carpenter

These NULL checks are reversed so the clone() can never succeed.

Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")

---
v2: fix a couple similar bugs

Gar. Nope. Missed one still.

regards,
dan carpenter

#2 lore raw
Quoted 9 lines · Dan Carpenter
Quoted 6 lines · Dan Carpenter

These NULL checks are reversed so the clone() can never succeed.

Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")

---
v2: fix a couple similar bugs

Gar. Nope. Missed one still.

Already fixed in net-next

#3 lore raw
Quoted 4 lines · Pablo Neira Ayuso
Quoted 3 lines · Dan Carpenter
Quoted 2 lines · Dan Carpenter

These NULL checks are reversed so the clone() can never succeed.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")

---
v2: fix a couple similar bugs

Gar. Nope. Missed one still.

Already fixed in net-next

Maybe I misunderstood. Are all four functions fixed?

I'm looking at net-next and nft_connlimit_clone() is still broken.

regards,
dan carpenter

#4 lore raw
Quoted 10 lines · Dan Carpenter
Quoted 9 lines · Pablo Neira Ayuso
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Dan Carpenter

These NULL checks are reversed so the clone() can never succeed.

Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")

---
v2: fix a couple similar bugs

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Gar. Nope. Missed one still.

Already fixed in net-next

Maybe I misunderstood. Are all four functions fixed?

I'm looking at net-next and nft_connlimit_clone() is still broken.

Sorry, patch in the net tree:

commit 51edb2ff1c6fc27d3fa73f0773a31597ecd8e230

Author: Pablo Neira Ayuso <[email protected]>
Date:   Mon Jan 10 20:48:17 2022 +0100

netfilter: nf_tables: typo NULL check in _clone() function

net-next is out of sync at this stage, until merge window reopens it might stay like this.