• Christoph Lameter's avatar
    [PATCH] slab: do not panic when alloc_kmemlist fails and slab is up · 2ed3a4ef
    Christoph Lameter authored
    It is fairly easy to get a system to oops by simply sizing a cache via
    /proc in such a way that one of the chaches (shared is easiest) becomes
    bigger than the maximum allowed slab allocation size.  This occurs because
    enable_cpucache() fails if it cannot reallocate some caches.
    
    However, enable_cpucache() is used for multiple purposes: resizing caches,
    cache creation and bootstrap.
    
    If the slab is already up then we already have working caches.  The resize
    can fail without a problem.  We just need to return the proper error code.
    F.e.  after this patch:
    
    # echo "size-64 10000 50 1000" >/proc/slabinfo
    -bash: echo: write error: Cannot allocate memory
    
    notice no OOPS.
    
    If we are doing a kmem_cache_create() then we also should not panic but
    return -ENOMEM.
    
    If on the other hand we do not have a fully bootstrapped slab allocator yet
    then we should indeed panic since we are unable to bring up the slab to its
    full functionality.
    Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
    Cc: Pekka Enberg <penberg@cs.helsinki.fi>
    Cc: Manfred Spraul <manfred@colorfullife.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    2ed3a4ef
slab.c 111 KB