[PATCH] Fix missing of last user info while getting

From: Shiyong Li
Date: Fri Apr 02 2010 - 02:50:30 EST


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 fix makes sure that redzone and last user tags get stored whatever
cache line.

Signed-off-by: Shiyong Li <shi-yong.li@xxxxxxxxxxxx>
---
mm/slab.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index a8a38ca..84af997 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2267,9 +2267,6 @@ kmem_cache_create (const char *name, size_t
size, size_t align,
if (ralign < align) {
ralign = align;
}
- /* disable debug if necessary */
- if (ralign > __alignof__(unsigned long long))
- flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
/*
* 4) Store it.
*/
@@ -2289,8 +2286,8 @@ kmem_cache_create (const char *name, size_t
size, size_t align,
*/
if (flags & SLAB_RED_ZONE) {
/* add space for red zone words */
- cachep->obj_offset += sizeof(unsigned long long);
- size += 2 * sizeof(unsigned long long);
+ cachep->obj_offset += align;
+ size += align + sizeof(unsigned long long);
}
if (flags & SLAB_STORE_USER) {
/* user store requires one word storage behind the end of
--
1.6.0.4


Thanks & Best Regards
Shiyong
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/