mm: slub: Panic instead of restoring corrupted bytes

Resiliency of slub was added for production systems in an
attempt to restore corruptions and allow production environments
to continue to run.

In debug setups, this may no be desirable. Thus rather than
attempting to restore corrupted bytes in poisoned zones, panic
to attempt to catch more context of what was going on in the
system at the time.

Add the CONFIG_SLUB_DEBUG_PANIC_ON defconfig option to allow
debug builds to turn on this panic option.

Change-Id: I01763e8eea40a4544e9b7e48c4e4d40840b6c82d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt
index 8465241..7ca432e 100644
--- a/Documentation/vm/slub.txt
+++ b/Documentation/vm/slub.txt
@@ -252,6 +252,10 @@
 tells us that SLUB has restored the Redzone to its proper value and then
 system operations continue.
 
+If it is required to only report the details of the issue and panic immediately
+after in order to possibly catch any scribblers one can set the
+CONFIG_DEBUG_SLUB_PANIC_ON option.
+
 Emergency operations:
 ---------------------
 
diff --git a/mm/slub.c b/mm/slub.c
index 7aa0e97..5111fcb 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -703,8 +703,12 @@
 static void restore_bytes(struct kmem_cache *s, char *message, u8 data,
 						void *from, void *to)
 {
+#ifdef CONFIG_SLUB_DEBUG_PANIC_ON
+	panic("Found corruption 0x%p-0x%p=0x%x\n", from, to - 1, data);
+#else
 	slab_fix(s, "Restoring 0x%p-0x%p=0x%x\n", from, to - 1, data);
 	memset(from, data, to - from);
+#endif
 }
 
 static int check_bytes_and_report(struct kmem_cache *s, struct page *page,