The patch titled Subject: mm-slub-freelist-randomization-fix has been removed from the -mm tree. Its filename was mm-reorganize-slab-freelist-randomization-fix.patch This patch was dropped because it was folded into mm-reorganize-slab-freelist-randomization.patch ------------------------------------------------------ From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Subject: mm-slub-freelist-randomization-fix freelist_randomize(), cache_random_seq_create() and cache_random_seq_destroy() should not be inside CONFIG_SLABINFO. Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: Thomas Garnier <thgarnie@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/slab_common.c | 94 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff -puN mm/slab_common.c~mm-reorganize-slab-freelist-randomization-fix mm/slab_common.c --- a/mm/slab_common.c~mm-reorganize-slab-freelist-randomization-fix +++ a/mm/slab_common.c @@ -1030,6 +1030,53 @@ void *kmalloc_order_trace(size_t size, g EXPORT_SYMBOL(kmalloc_order_trace); #endif +#ifdef CONFIG_SLAB_FREELIST_RANDOM +/* Randomize a generic freelist */ +static void freelist_randomize(struct rnd_state *state, unsigned int *list, + size_t count) +{ + size_t i; + unsigned int rand; + + for (i = 0; i < count; i++) + list[i] = i; + + /* Fisher-Yates shuffle */ + for (i = count - 1; i > 0; i--) { + rand = prandom_u32_state(state); + rand %= (i + 1); + swap(list[i], list[rand]); + } +} + +/* Create a random sequence per cache */ +int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count, + gfp_t gfp) +{ + struct rnd_state state; + + if (count < 2 || cachep->random_seq) + return 0; + + cachep->random_seq = kcalloc(count, sizeof(unsigned int), gfp); + if (!cachep->random_seq) + return -ENOMEM; + + /* Get best entropy at this stage of boot */ + prandom_seed_state(&state, get_random_long()); + + freelist_randomize(&state, cachep->random_seq, count); + return 0; +} + +/* Destroy the per-cache random freelist sequence */ +void cache_random_seq_destroy(struct kmem_cache *cachep) +{ + kfree(cachep->random_seq); + cachep->random_seq = NULL; +} +#endif /* CONFIG_SLAB_FREELIST_RANDOM */ + #ifdef CONFIG_SLABINFO #ifdef CONFIG_SLAB @@ -1142,53 +1189,6 @@ int memcg_slab_show(struct seq_file *m, } #endif -#ifdef CONFIG_SLAB_FREELIST_RANDOM -/* Randomize a generic freelist */ -static void freelist_randomize(struct rnd_state *state, unsigned int *list, - size_t count) -{ - size_t i; - unsigned int rand; - - for (i = 0; i < count; i++) - list[i] = i; - - /* Fisher-Yates shuffle */ - for (i = count - 1; i > 0; i--) { - rand = prandom_u32_state(state); - rand %= (i + 1); - swap(list[i], list[rand]); - } -} - -/* Create a random sequence per cache */ -int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count, - gfp_t gfp) -{ - struct rnd_state state; - - if (count < 2 || cachep->random_seq) - return 0; - - cachep->random_seq = kcalloc(count, sizeof(unsigned int), gfp); - if (!cachep->random_seq) - return -ENOMEM; - - /* Get best entropy at this stage of boot */ - prandom_seed_state(&state, get_random_long()); - - freelist_randomize(&state, cachep->random_seq, count); - return 0; -} - -/* Destroy the per-cache random freelist sequence */ -void cache_random_seq_destroy(struct kmem_cache *cachep) -{ - kfree(cachep->random_seq); - cachep->random_seq = NULL; -} -#endif /* CONFIG_SLAB_FREELIST_RANDOM */ - /* * slabinfo_op - iterator that generates /proc/slabinfo * _ Patches currently in -mm which might be from akpm@xxxxxxxxxxxxxxxxxxxx are mm-reorganize-slab-freelist-randomization.patch mm-balloon-use-general-non-lru-movable-page-feature-fix.patch mm-compaction-split-freepages-without-holding-the-zone-lock-fix-2.patch mm-frontswap-convert-frontswap_enabled-to-static-key-checkpatch-fixes.patch mm-add-nr_zsmalloc-to-vmstat-fix.patch mm-memcg-use-consistent-gfp-flags-during-readahead-checkpatch-fixes.patch mm-thp-make-swapin-readahead-under-down_read-of-mmap_sem-fix-2-fix.patch mm-fix-build-warnings-in-linux-compactionh-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html