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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1de6b098-a759-dd96-df5d-9a282b2a991b@infradead.org>
Date:   Fri, 26 Jun 2020 13:56:47 -0700
From:   Randy Dunlap <rdunlap@...radead.org>
To:     Kees Cook <keescook@...omium.org>, akpm@...ux-foundation.org
Cc:     broonie@...nel.org, mhocko@...e.cz, sfr@...b.auug.org.au,
        linux-next@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        mm-commits@...r.kernel.org
Subject: Re: [PATCH] slab: Fix misplaced __free_one()

On 6/26/20 1:07 PM, Kees Cook wrote:
> The implementation of __free_one() was accidentally placed inside a
> CONFIG_NUMA #ifdef. Move it above.
> 
> Reported-by: Randy Dunlap <rdunlap@...radead.org>
> Link: https://lore.kernel.org/lkml/7ff248c7-d447-340c-a8e2-8c02972aca70@infradead.org
> Signed-off-by: Kees Cook <keescook@...omium.org>

Acked-by: Randy Dunlap <rdunlap@...radead.org> # build-tested

Thanks.

> ---
> This a fix for slab-add-naive-detection-of-double-free.patch
> ---
>  mm/slab.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index bbff6705ab2b..5ccb151a6e8f 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -588,6 +588,16 @@ static int transfer_objects(struct array_cache *to,
>  	return nr;
>  }
>  
> +/* &alien->lock must be held by alien callers. */
> +static __always_inline void __free_one(struct array_cache *ac, void *objp)
> +{
> +	/* Avoid trivial double-free. */
> +	if (IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) &&
> +	    WARN_ON_ONCE(ac->avail > 0 && ac->entry[ac->avail - 1] == objp))
> +		return;
> +	ac->entry[ac->avail++] = objp;
> +}
> +
>  #ifndef CONFIG_NUMA
>  
>  #define drain_alien_cache(cachep, alien) do { } while (0)
> @@ -749,16 +759,6 @@ static void drain_alien_cache(struct kmem_cache *cachep,
>  	}
>  }
>  
> -/* &alien->lock must be held by alien callers. */
> -static __always_inline void __free_one(struct array_cache *ac, void *objp)
> -{
> -	/* Avoid trivial double-free. */
> -	if (IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) &&
> -	    WARN_ON_ONCE(ac->avail > 0 && ac->entry[ac->avail - 1] == objp))
> -		return;
> -	ac->entry[ac->avail++] = objp;
> -}
> -
>  static int __cache_free_alien(struct kmem_cache *cachep, void *objp,
>  				int node, int page_node)
>  {
> 


-- 
~Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ