Skip to content

Commit

Permalink
slub: cure list_slab_objects() from double fix
Browse files Browse the repository at this point in the history
According to Christopher Lameter two fixes have been merged for the same
problem.  As far as I can tell, the code does not acquire the list_lock
and invoke kmalloc().  list_slab_objects() misses an unlock (the
counterpart to get_map()) and the memory allocated in free_partial()
isn't used.

Revert the mentioned commit.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: aa456c7 ("slub: remove kmalloc under list_lock from list_slab_objects() V2")
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Yu Zhao <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Sebastian Andrzej Siewior authored and torvalds committed Jun 26, 2020
1 parent 8982ae5 commit 55860d9
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3766,15 +3766,13 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags)
}

static void list_slab_objects(struct kmem_cache *s, struct page *page,
const char *text, unsigned long *map)
const char *text)
{
#ifdef CONFIG_SLUB_DEBUG
void *addr = page_address(page);
unsigned long *map;
void *p;

if (!map)
return;

slab_err(s, page, text, s->name);
slab_lock(page);

Expand All @@ -3786,6 +3784,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
print_tracking(s, p);
}
}
put_map(map);
slab_unlock(page);
#endif
}
Expand All @@ -3799,11 +3798,6 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
{
LIST_HEAD(discard);
struct page *page, *h;
unsigned long *map = NULL;

#ifdef CONFIG_SLUB_DEBUG
map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
#endif

BUG_ON(irqs_disabled());
spin_lock_irq(&n->list_lock);
Expand All @@ -3813,16 +3807,11 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
list_add(&page->slab_list, &discard);
} else {
list_slab_objects(s, page,
"Objects remaining in %s on __kmem_cache_shutdown()",
map);
"Objects remaining in %s on __kmem_cache_shutdown()");
}
}
spin_unlock_irq(&n->list_lock);

#ifdef CONFIG_SLUB_DEBUG
bitmap_free(map);
#endif

list_for_each_entry_safe(page, h, &discard, slab_list)
discard_slab(s, page);
}
Expand Down

0 comments on commit 55860d9

Please sign in to comment.