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: <YPgKXBTjgO6ko0qQ@kroah.com>
Date:   Wed, 21 Jul 2021 13:51:56 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Xiyu Yang <xiyuyang19@...an.edu.cn>
Cc:     Dimitri Sivanich <dimitri.sivanich@....com>,
        Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
        yuanxzhang@...an.edu.cn, Xin Tan <tanxin.ctf@...il.com>
Subject: Re: [PATCH] misc: sgi-gru: Convert from atomic_t to refcount_t on
 gru_thread_state->ts_refcnt

On Sat, Jul 17, 2021 at 06:17:22PM +0800, Xiyu Yang wrote:
> refcount_t type and corresponding API can protect refcounters from
> accidental underflow and overflow and further use-after-free situations.
> 
> Signed-off-by: Xiyu Yang <xiyuyang19@...an.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@...il.com>
> ---
>  drivers/misc/sgi-gru/grumain.c   | 6 +++---
>  drivers/misc/sgi-gru/grutables.h | 3 ++-
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/misc/sgi-gru/grumain.c b/drivers/misc/sgi-gru/grumain.c
> index 40ac59dd018c..9afda47efbf2 100644
> --- a/drivers/misc/sgi-gru/grumain.c
> +++ b/drivers/misc/sgi-gru/grumain.c
> @@ -282,7 +282,7 @@ static void gru_unload_mm_tracker(struct gru_state *gru,
>   */
>  void gts_drop(struct gru_thread_state *gts)
>  {
> -	if (gts && atomic_dec_return(&gts->ts_refcnt) == 0) {
> +	if (gts && refcount_dec_and_test(&gts->ts_refcnt)) {
>  		if (gts->ts_gms)
>  			gru_drop_mmu_notifier(gts->ts_gms);
>  		kfree(gts);

Related to this, shouldn't this really be a 'struct kref' instead of
hand-creating the exact same logic?

Want to make that change on top of this one?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ