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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6de91cc3-3942-471b-9f89-5eec144fb33e@suse.cz>
Date: Wed, 7 Aug 2024 12:34:38 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Pedro Falcato <pedro.falcato@...il.com>, Christoph Lameter
 <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>,
 David Rientjes <rientjes@...gle.com>, Joonsoo Kim <iamjoonsoo.kim@....com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: Roman Gushchin <roman.gushchin@...ux.dev>,
 Hyeonggon Yoo <42.hyeyoo@...il.com>, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] slab: Warn on duplicate cache names when DEBUG_VM=y

On 8/7/24 11:07, Pedro Falcato wrote:
> Duplicate slab cache names can create havoc for userspace tooling that
> expects slab cache names to be unique. This is a reasonable expectation.
> 
> Sadly, too many duplicate name problems are out there in the wild, so
> simply pr_warn instead of pr_err() + failing the sanity check.
> 
> Link: https://lore.kernel.org/linux-fsdevel/2d1d053da1cafb3e7940c4f25952da4f0af34e38.1722293276.git.osandov@fb.com/
> Signed-off-by: Pedro Falcato <pedro.falcato@...il.com>
> ---
> v2:
>  - Replace the pr_err() + failure with a simple pr_warn
> 
> Contrary to Vlastimil's suggestion, we don't seem to require a refcount
> == 0 check, because shutdown_cache already synchronously deletes the cache from the list (even reusing
> the same list_head for TYPESAFE_BY_RCU).

It's not deleted when leaked objects are detected and the destroy is
aborted. But in this series that should no longer happen so then it will be
fine:

https://lore.kernel.org/all/20240807-b4-slab-kfree_rcu-destroy-v2-0-ea79102f428c@suse.cz/

> 
>  mm/slab_common.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 40b582a014b..1abe6a577d5 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -88,6 +88,19 @@ unsigned int kmem_cache_size(struct kmem_cache *s)
>  EXPORT_SYMBOL(kmem_cache_size);
>  
>  #ifdef CONFIG_DEBUG_VM
> +
> +static bool kmem_cache_is_duplicate_name(const char *name)
> +{
> +	struct kmem_cache *s;
> +
> +	list_for_each_entry(s, &slab_caches, list) {
> +		if (!strcmp(s->name, name))
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  static int kmem_cache_sanity_check(const char *name, unsigned int size)
>  {
>  	if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) {
> @@ -95,6 +108,11 @@ static int kmem_cache_sanity_check(const char *name, unsigned int size)
>  		return -EINVAL;
>  	}
>  
> +	if (kmem_cache_is_duplicate_name(name)) {
> +		/* Duplicate names will confuse slabtop, et al */
> +		pr_warn("%s: name %s already exists as a cache\n", __func__, name);
> +	}
> +
>  	WARN_ON(strchr(name, ' '));	/* It confuses parsers */
>  	return 0;
>  }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ