SLUB: Add padding after metadata when debugging Without padding there is the danger that we do not notice writing before the allocated object. So increase the slab size by another word in the debug case. That will force the creation of some fill space which SLUB will continue to check. Signed-off-by: Christoph Lameter Index: linux-2.6.21-rc6/mm/slub.c =================================================================== --- linux-2.6.21-rc6.orig/mm/slub.c 2007-04-12 16:44:13.000000000 -0700 +++ linux-2.6.21-rc6/mm/slub.c 2007-04-12 16:45:18.000000000 -0700 @@ -484,7 +484,7 @@ static int check_object(struct kmem_cach if (s->flags & SLAB_POISON) { if (!active && (s->flags & __OBJECT_POISON) && (!check_bytes(p, POISON_FREE, s->objsize - 1) || - p[s->objsize -1] != POISON_END)) { + p[s->objsize - 1] != POISON_END)) { object_err(s, page, p, "Poison check failed"); return 0; } @@ -1623,6 +1623,15 @@ static int calculate_sizes(struct kmem_c */ size += 2 * sizeof(struct track); + if (flags & DEBUG_DEFAULT_FLAGS) + /* + * Add some empty padding so that we can catch + * overwrites from earlier objects rather than let + * tracking information or the free pointer be + * corrupted if an user writes before the start + * of the object. + */ + size += sizeof(void *); /* * Determine the alignment based on various parameters that the * user specified (this is unecessarily complex due to the attempt