Skip to content

Commit

Permalink
mm/slub.c: fix random_seq offset destruction
Browse files Browse the repository at this point in the history
Commit 210e7a4 ("mm: SLUB freelist randomization") broke USB hub
initialisation as described in

  https://bugzilla.kernel.org/show_bug.cgi?id=177551.

Bail out early from init_cache_random_seq if s->random_seq is already
initialised.  This prevents destroying the previously computed
random_seq offsets later in the function.

If the offsets are destroyed, then shuffle_freelist will truncate
page->freelist to just the first object (orphaning the rest).

Fixes: 210e7a4 ("mm: SLUB freelist randomization")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Sean Rees <[email protected]>
Reported-by: <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Thomas Garnier <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
seanrees authored and torvalds committed Feb 8, 2017
1 parent 4d59b6c commit a810007
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,10 @@ static int init_cache_random_seq(struct kmem_cache *s)
int err;
unsigned long i, count = oo_objects(s->oo);

/* Bailout if already initialised */
if (s->random_seq)
return 0;

err = cache_random_seq_create(s, count, GFP_KERNEL);
if (err) {
pr_err("SLUB: Unable to initialize free list for %s\n",
Expand Down

0 comments on commit a810007

Please sign in to comment.