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: <CAKbZUD1e5nvmrQ5XZ=xV1eYbh5eeSLBQEeDT=KBx1C5T1Bjjzg@mail.gmail.com>
Date: Sun, 11 Aug 2024 23:28:35 +0100
From: Pedro Falcato <pedro.falcato@...il.com>
To: David Rientjes <rientjes@...gle.com>
Cc: Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>, 
	Joonsoo Kim <iamjoonsoo.kim@....com>, Andrew Morton <akpm@...ux-foundation.org>, 
	Vlastimil Babka <vbabka@...e.cz>, 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 Sun, Aug 11, 2024 at 9:30 PM David Rientjes <rientjes@...gle.com> wrote:
>
> On Wed, 7 Aug 2024, Pedro Falcato wrote:
>
> > 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);
>
>
> Shouldn't this be a full WARN_ON() instead of pr_warn()?  I assume we'll
> be interested in who is adding the cache when the name already exists.

panic_on_warn? :)

Personally I don't have anything against WARN_ON, but we've seen that
panic_on_warn is a real thing on real systems, and DEBUG_VM is also
set on real prod configs (like Fedora does/used to do). I've sent out
one or two loose patches for problems I did find in my own testing
around, but there may be many more (e.g some drivers may call
kmem_cache_create repeatedly in some sort of callback, like 9pfs was
doing when mounting; this is not greppable). And I'd guess grepping
for cache names tends to be easy enough?

-- 
Pedro

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ