netfilter: nft_connlimit: fix nft_connlimit_clone()
Subsystems (3)
PATCH 1/1 netfilter: nft_connlimit: fix nft_connlimit_clone()
The NULL check is reversed so nft_connlimit_clone() can never succeed.
---
Haha haha. A couple months back I accidentally reversed a NULL check and invested several days in writing multiple Smatch checks to make sure that never happened again. Everyone made fun of me for wasting my time but who's laughing now? ha ha. <- me
net/netfilter/nft_connlimit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_connlimit.c +1 -1
@@ -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);
Signature · 1 line
2.20.1
Quoted 18 lines · Dan Carpenter
The NULL check is reversed so
nft_connlimit_clone()can never succeed.Fixes 37f319f37d90 ("netfilter: nft_connlimit: move stateful fields out of expression data")Signed-off-by Dan Carpenter <[email protected]>---
Haha haha. A couple months back I accidentally reversed a NULL check and invested several days in writing multiple Smatch checks to make sure that never happened again. Everyone made fun of me for wasting my time but who's laughing now? ha ha. <- menet/netfilter/nft_connlimit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/netfilter/nft_connlimit.c +0
-0
net/netfilter/nft_connlimit.c static int nft_connlimit_clone(struct nft_expr *dst, const struct nft_expr *src) · line 212
Quoted 8 lines
net/netfilter/nft_connlimit.c +1
-1@@ -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);
Ugh... Hold of on this. I'll send v2. nft_last_clone() has a similar issue.
regards,
dan carpenter