Commit a810007a authored by Sean Rees's avatar Sean Rees Committed by Linus Torvalds

mm/slub.c: fix random_seq offset destruction

Commit 210e7a43 ("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: 210e7a43 ("mm: SLUB freelist randomization")
Link: http://lkml.kernel.org/r/20170207140707.20824-1-sean@erifax.orgSigned-off-by: default avatarSean Rees <sean@erifax.org>
Reported-by: <userwithuid@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4d59b6cc
...@@ -1422,6 +1422,10 @@ static int init_cache_random_seq(struct kmem_cache *s) ...@@ -1422,6 +1422,10 @@ static int init_cache_random_seq(struct kmem_cache *s)
int err; int err;
unsigned long i, count = oo_objects(s->oo); 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); err = cache_random_seq_create(s, count, GFP_KERNEL);
if (err) { if (err) {
pr_err("SLUB: Unable to initialize free list for %s\n", pr_err("SLUB: Unable to initialize free list for %s\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment