Re: [patch] mm, slab: initialize object alignment on cache creation
On Tue, 23 Sep 2014, David Rientjes wrote: > Previous to commit 4590685546a3 ("mm/sl[aou]b: Common alignment code") > which introduced this issue. Ah. Ok. I see and approve. Acked-by: Christoph Lameter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch] mm, slab: initialize object alignment on cache creation
On Tue, 23 Sep 2014, Christoph Lameter wrote: > > The proper alignment defaults to BYTES_PER_WORD and can be overridden by > > SLAB_RED_ZONE or the alignment specified by the caller. > > Where does it default to BYTES_PER_WORD in __kmem_cache_create? > Previous to commit 4590685546a3 ("mm/sl[aou]b: Common alignment code") which introduced this issue. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch] mm, slab: initialize object alignment on cache creation
On Tue, 23 Sep 2014, David Rientjes wrote: > The proper alignment defaults to BYTES_PER_WORD and can be overridden by > SLAB_RED_ZONE or the alignment specified by the caller. Where does it default to BYTES_PER_WORD in __kmem_cache_create? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch] mm, slab: initialize object alignment on cache creation
Since 4590685546a3 ("mm/sl[aou]b: Common alignment code"), the "ralign" automatic variable in __kmem_cache_create() may be used as uninitialized. The proper alignment defaults to BYTES_PER_WORD and can be overridden by SLAB_RED_ZONE or the alignment specified by the caller. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=85031 Reported-by: Andrei Elovikov Signed-off-by: David Rientjes --- a.elovikov: If you respond to this email with your full name, Andrew can give proper credit for reporting this issue. mm/slab.c | 11 ++- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mm/slab.c b/mm/slab.c --- a/mm/slab.c +++ b/mm/slab.c @@ -2128,7 +2128,8 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp) int __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) { - size_t left_over, freelist_size, ralign; + size_t left_over, freelist_size; + size_t ralign = BYTES_PER_WORD; gfp_t gfp; int err; size_t size = cachep->size; @@ -2161,14 +2162,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) size &= ~(BYTES_PER_WORD - 1); } - /* -* Redzoning and user store require word alignment or possibly larger. -* Note this will be overridden by architecture or caller mandated -* alignment if either is greater than BYTES_PER_WORD. -*/ - if (flags & SLAB_STORE_USER) - ralign = BYTES_PER_WORD; - if (flags & SLAB_RED_ZONE) { ralign = REDZONE_ALIGN; /* If redzoning, ensure that the second redzone is suitably -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/