From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753321AbZG2AHL (ORCPT ); Tue, 28 Jul 2009 20:07:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753217AbZG2AHK (ORCPT ); Tue, 28 Jul 2009 20:07:10 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:51956 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753183AbZG2AHI (ORCPT ); Tue, 28 Jul 2009 20:07:08 -0400 Date: Tue, 28 Jul 2009 17:06:32 -0700 From: Andrew Morton To: Benjamin Herrenschmidt Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Pekka Enberg Subject: Re: [PATCH] mm: Make it easier to catch NULL cache names Message-Id: <20090728170632.2d136ce6.akpm@linux-foundation.org> In-Reply-To: <1248754289.30993.45.camel@pasglop> References: <1248754289.30993.45.camel@pasglop> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Jul 2009 14:11:29 +1000 Benjamin Herrenschmidt wrote: > Right now, if you inadvertently pass NULL to kmem_cache_create() at boot > time, it crashes much later after boot somewhere deep inside sysfs which > makes it very non obvious to figure out what's going on. That must have been a pretty dumb piece of kernel code. It's a bit questionable (IMO) whether we need to cater for really exceptional bugs. But whatever. slab used to have a check (__get_user) to see whether the ->name field was still readable. This was to detect the case where the slab cache was created from a kernel module and the module forgot to remove the cache at rmmod-time. Subsequent reads of /proc/slabinfo would confusingly go splat. The check seems to have been removed (from slab.c, at least). If it is still there then it should be applied consistently and across all slab versions. In which case that check would make your patch arguably-unneeded. But it seems to have got itself zapped. > Signed-off-by: Benjamin Herrenschmidt > --- > > Yes, I did hit that :-) Something in ppc land using an array of caches > and got the names array out of sync with changes to the list of indices. > > mm/slub.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index b9f1491..e31fbe6 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3292,6 +3292,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, > { > struct kmem_cache *s; > > + if (WARN_ON(!name)) > + return NULL; > + > down_write(&slub_lock); > s = find_mergeable(size, align, flags, name, ctor); > if (s) { Let's see: slab.c: goes BUG slob.c: will apparently go oops at some later time slqb.c: does dump_stack(), returns NULL from kmem_cache_create() slub.c: does WARN(), returns NULL from kmem_cache_create() I think I'll apply the patch, cc Pekka then run away.