[PATCH] Fix missing of last user while dumping slab corruption log

From: ShiYong LI
Date: Fri Apr 02 2010 - 03:21:49 EST


Hi,

Even with SLAB_RED_ZONE and SLAB_STORE_USER enabled, kernel would NOT
store redzone and last user data around allocated memory space if arch
cache line > sizeof(unsigned long long). As a result, last user information
is unexpectedly MISSED while dumping slab corruption log.

This patch makes sure that redzone and last user tags get stored whatever
arch cache line.

Compared to original codes, the change surely affects head redzone (redzone1).
Actually, with SLAB_RED_ZONE and SLAB_STORE_USER enabled,
allocated memory layout is as below:

[ redzone1 ] <--------- Affected area.
[ real object space ]
[ redzone2 ]
[ last user ]
[ ... ]

Let's do some analysis: (whatever SLAB_STORE_USER is).

1) With SLAB_RED_ZONE on, "align" >= sizeof(unsigned long long) according to
the following codes:
/* 2) arch mandated alignment */
if (ralign < ARCH_SLAB_MINALIGN) {
ralign = ARCH_SLAB_MINALIGN;
}
/* 3) caller mandated alignment */
if (ralign < align) {
ralign = align;
}
...
/*
* 4) Store it.
*/
align = ralign;

That's to say, could guarantee that redzone1 does NOT get broken
at all. Meanwhile,
Real object space could meet the need of cache line size by using
"align" argument.

2) With SLAB_RED_ZONE off, the change has no impact.