[PATCH] Move slab objects to the end of the real allocation
From: Manfred Spraul <manfred@colorfullife.com> The real memory allocation is usually larger than the actual object size: either due to L1 cache line padding, or due to page padding with CONFIG_DEBUG_PAGEALLOC. Right now objects are placed to the beginning of the real allocation, but to trigger bugs it's better to move objects to the end of the real allocation: that way accesses behind the end of the allocation have a larger chance of hitting the (unmapped) next page. The attached patch moves the objects to align them with the end of the real allocation. Actually it contains 4 seperate changes: - Do not page-pad allocations that are <= SMP_CACHE_LINE_SIZE. This crashes. Right now the limit is hardcoded to 128 bytes, but sooner or later an arch will appear with 256 byte cache lines. - cleanup: redzone bytes are not accessed with inline helper functions, instead of magic offsets scattered throughout slab.c - main change: move objects to the end of the allocation - trivial after the cleanup. - Print old redzone value if a redzone mismatch happens: This makes it simpler to figure out what happened [single bit error, wrong redzone code, overwritten]
Showing
Please register or sign in to comment