All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] netfilter: nft_connlimit: fix nft_connlimit_clone()
@ 2022-01-11  5:22 Dan Carpenter
  2022-01-11  5:27 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-01-11  5:22 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, Florian Westphal, netfilter-devel, coreteam,
	kernel-janitors

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 <dan.carpenter@oracle.com>
---
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(-)

diff --git a/net/netfilter/nft_connlimit.c b/net/netfilter/nft_connlimit.c
index 58dcafe8bf79..7d00a1452b1d 100644
--- a/net/netfilter/nft_connlimit.c
+++ b/net/netfilter/nft_connlimit.c
@@ -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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] netfilter: nft_connlimit: fix nft_connlimit_clone()
  2022-01-11  5:22 [PATCH net-next] netfilter: nft_connlimit: fix nft_connlimit_clone() Dan Carpenter
@ 2022-01-11  5:27 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2022-01-11  5:27 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, Florian Westphal, netfilter-devel, coreteam,
	kernel-janitors

On Tue, Jan 11, 2022 at 08:22:34AM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
> 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(-)
> 
> diff --git a/net/netfilter/nft_connlimit.c b/net/netfilter/nft_connlimit.c
> index 58dcafe8bf79..7d00a1452b1d 100644
> --- a/net/netfilter/nft_connlimit.c
> +++ b/net/netfilter/nft_connlimit.c
> @@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-11  5:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  5:22 [PATCH net-next] netfilter: nft_connlimit: fix nft_connlimit_clone() Dan Carpenter
2022-01-11  5:27 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.