提交 d4a5fca5 编写于 作者: D David Rientjes 提交者: Linus Torvalds

mm, slab: initialize object alignment on cache creation

Since commit 45906855 ("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=85031Signed-off-by: NDavid Rientjes <rientjes@google.com>
Reported-by: NAndrei Elovikov <a.elovikov@gmail.com>
Acked-by: NChristoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 87e6d49a
...@@ -2124,7 +2124,8 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp) ...@@ -2124,7 +2124,8 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
int int
__kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) __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; gfp_t gfp;
int err; int err;
size_t size = cachep->size; size_t size = cachep->size;
...@@ -2157,14 +2158,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) ...@@ -2157,14 +2158,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
size &= ~(BYTES_PER_WORD - 1); 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) { if (flags & SLAB_RED_ZONE) {
ralign = REDZONE_ALIGN; ralign = REDZONE_ALIGN;
/* If redzoning, ensure that the second redzone is suitably /* If redzoning, ensure that the second redzone is suitably
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册