fix potential stack overflow in mm/slab.c
PATCH 1/1 fix potential stack overflow in mm/slab.c
On High end systems (1024 or so cpus) this can potentially cause stack overflow. Fix the stack usage.
Signed-off-by Suresh Siddha <[email protected]>
mm/slab.c renamed from mm/slab.c~ +15 -8
@@ -3603,22 +3603,27 @@ static void do_ccupdate_local(void *infostatic int do_tune_cpucache (struct kmem_cache *cachep,int limit,int batchcount,int shared) { -struct ccupdate_struct new; +struct ccupdate_struct *new;int i, err; -memset (&new.new,0 ,sizeof (new.new)); + new =kmalloc (sizeof (*new),GFP_KERNEL ); +if (!new) +return -ENOMEM ; + +memset (&new->new,0 ,sizeof (new->new));for_each_online_cpu (i) { - new.new[i] =alloc_arraycache (cpu_to_node (i), limit, + new->new[i] =alloc_arraycache (cpu_to_node (i), limit, batchcount); -if (!new.new[i]) { +if (!new->new[i]) {for (i--; i >=0 ; i--) -kfree (new.new[i]); +kfree (new->new[i]); +kfree (new);return -ENOMEM ; } } - new.cachep = cachep; + new->cachep = cachep; -on_each_cpu (do_ccupdate_local, (void *)&new,1 ,1 ); +on_each_cpu (do_ccupdate_local, (void *)new,1 ,1 );check_irq_on (); cachep->batchcount = batchcount;
@@ -3626,7 +3631,7 @@ static int do_tune_cpucache(struct kmem_ cachep->shared = shared;for_each_online_cpu (i) { -struct array_cache *ccold = new.new[i]; +struct array_cache *ccold = new->new[i];if (!ccold)continue ;spin_lock_irq (&cachep->nodelists[cpu_to_node (i)]->list_lock);
@@ -3641,6 +3646,8 @@ static int do_tune_cpucache(struct kmem_ cachep->name, -err);BUG (); } + +kfree (new);return 0 ; }