From 5aabb433387a621cffe49cdaad8593ae03ac6226 Mon Sep 17 00:00:00 2001 From: David Keitel Date: Tue, 21 Oct 2014 16:26:17 -0700 Subject: [PATCH] mm: slub: panic for object and slab errors If the SLUB_DEBUG_PANIC_ON Kconfig option is selected, also panic for object and slab errors to allow capturing relevant debug data. Change-Id: Idc582ef48d3c0d866fa89cf8660ff0a5402f7e15 Signed-off-by: David Keitel Signed-off-by: Patrick Daly --- mm/slub.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 8da34a8af53d..0fc48b479bb0 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -687,11 +687,21 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) dump_stack(); } +#ifdef CONFIG_SLUB_DEBUG_PANIC_ON +static void slab_panic(const char *cause) +{ + panic("%s\n", cause); +} +#else +static inline void slab_panic(const char *cause) {} +#endif + void object_err(struct kmem_cache *s, struct page *page, u8 *object, char *reason) { slab_bug(s, "%s", reason); print_trailer(s, page, object); + slab_panic(reason); } static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, @@ -706,6 +716,7 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, slab_bug(s, "%s", buf); print_page_info(page); dump_stack(); + slab_panic("slab error"); } static void init_object(struct kmem_cache *s, void *object, u8 val) @@ -727,6 +738,7 @@ static void init_object(struct kmem_cache *s, void *object, u8 val) static void restore_bytes(struct kmem_cache *s, char *message, u8 data, void *from, void *to) { + slab_panic("object poison overwritten"); slab_fix(s, "Restoring 0x%p-0x%p=0x%x\n", from, to - 1, data); memset(from, data, to - from); }