lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89i+7OrEtM18hPjfjnZ9wf04KJ2NQsKDAV5dVwPV2UYwsPA@mail.gmail.com>
Date: Mon, 15 Apr 2024 19:33:01 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Abhinav Jain <jain.abhinav177@...il.com>
Cc: davem@...emloft.net, dsahern@...nel.org, kuba@...nel.org, 
	pabeni@...hat.com, netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
	skhan@...uxfoundation.org, javier.carrasco.cruz@...il.com
Subject: Re: [PATCH] inet: inet_defrag: Removing the usage of refcount_inc_not_zero

On Mon, Apr 15, 2024 at 6:06 PM Abhinav Jain <jain.abhinav177@...il.com> wrote:
>
> Remove refcount_inc_not_zero as per the listed TODO in the file.
> Used spin_(un)lock and refcount_* functions for synchronization.
>
> Signed-off-by: Abhinav Jain <jain.abhinav177@...il.com>
> ---
>  net/ipv4/inet_fragment.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
> index c88c9034d630..e4838bbe0abb 100644
> --- a/net/ipv4/inet_fragment.c
> +++ b/net/ipv4/inet_fragment.c
> @@ -358,7 +358,6 @@ static struct inet_frag_queue *inet_frag_create(struct fqdir *fqdir,
>         return q;
>  }
>
> -/* TODO : call from rcu_read_lock() and no longer use refcount_inc_not_zero() */
>  struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key)
>  {
>         /* This pairs with WRITE_ONCE() in fqdir_pre_exit(). */
> @@ -375,8 +374,14 @@ struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key)
>                 fq = inet_frag_create(fqdir, key, &prev);
>         if (!IS_ERR_OR_NULL(prev)) {
>                 fq = prev;
> -               if (!refcount_inc_not_zero(&fq->refcnt))
> +               spin_lock(&fq->lock);
> +               if (refcount_read(&fq->refcnt) > 0) {
> +                       refcount_inc(&fq->refcnt);
> +                       spin_unlock(&fq->lock);
> +               } else {
> +                       spin_unlock(&fq->lock);
>                         fq = NULL;
> +               }
>

This is bogus. I do not think you understood the comment.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ