Loading include/linux/bug.h +5 −0 Original line number Diff line number Diff line Loading @@ -81,4 +81,9 @@ static inline __must_check bool check_data_corruption(bool v) { return v; } corruption; \ })) #ifdef CONFIG_PANIC_ON_DATA_CORRUPTION #define PANIC_CORRUPTION 1 #else #define PANIC_CORRUPTION 0 #endif /* CONFIG_PANIC_ON_DATA_CORRUPTION */ #endif /* _LINUX_BUG_H */ lib/Kconfig.debug +9 −0 Original line number Diff line number Diff line Loading @@ -2134,6 +2134,15 @@ config BUG_ON_DATA_CORRUPTION If unsure, say N. config PANIC_ON_DATA_CORRUPTION bool "Cause a Kernel Panic When Data Corruption is detected" help Select this option to upgrade warnings for potentially recoverable data corruption scenarios to system-halting panics, for easier detection and debug. If we do not panic immediately after corruptions have been detected, the problem context is lost in the ensuing system mayhem. source "samples/Kconfig" source "lib/Kconfig.kgdb" Loading mm/page_poison.c +8 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ static bool single_bit_flip(unsigned char a, unsigned char b) return error && !(error & (error - 1)); } static void check_poison_mem(unsigned char *mem, size_t bytes) static void check_poison_mem(struct page *page, unsigned char *mem, size_t bytes) { static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10); unsigned char *start; Loading @@ -85,12 +86,15 @@ static void check_poison_mem(unsigned char *mem, size_t bytes) if (!__ratelimit(&ratelimit)) return; else if (start == end && single_bit_flip(*start, PAGE_POISON)) pr_err("pagealloc: single bit error\n"); pr_err("pagealloc: single bit error on page with phys start 0x%lx\n", (unsigned long)page_to_phys(page)); else pr_err("pagealloc: memory corruption\n"); pr_err("pagealloc: memory corruption on page with phys start 0x%lx\n", (unsigned long)page_to_phys(page)); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, start, end - start + 1, 1); BUG_ON(PANIC_CORRUPTION); dump_stack(); } Loading @@ -104,7 +108,7 @@ static void unpoison_page(struct page *page) * that is freed to buddy. Thus no extra check is done to * see if a page was poisoned. */ check_poison_mem(addr, PAGE_SIZE); check_poison_mem(page, addr, PAGE_SIZE); kunmap_atomic(addr); } Loading Loading
include/linux/bug.h +5 −0 Original line number Diff line number Diff line Loading @@ -81,4 +81,9 @@ static inline __must_check bool check_data_corruption(bool v) { return v; } corruption; \ })) #ifdef CONFIG_PANIC_ON_DATA_CORRUPTION #define PANIC_CORRUPTION 1 #else #define PANIC_CORRUPTION 0 #endif /* CONFIG_PANIC_ON_DATA_CORRUPTION */ #endif /* _LINUX_BUG_H */
lib/Kconfig.debug +9 −0 Original line number Diff line number Diff line Loading @@ -2134,6 +2134,15 @@ config BUG_ON_DATA_CORRUPTION If unsure, say N. config PANIC_ON_DATA_CORRUPTION bool "Cause a Kernel Panic When Data Corruption is detected" help Select this option to upgrade warnings for potentially recoverable data corruption scenarios to system-halting panics, for easier detection and debug. If we do not panic immediately after corruptions have been detected, the problem context is lost in the ensuing system mayhem. source "samples/Kconfig" source "lib/Kconfig.kgdb" Loading
mm/page_poison.c +8 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ static bool single_bit_flip(unsigned char a, unsigned char b) return error && !(error & (error - 1)); } static void check_poison_mem(unsigned char *mem, size_t bytes) static void check_poison_mem(struct page *page, unsigned char *mem, size_t bytes) { static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10); unsigned char *start; Loading @@ -85,12 +86,15 @@ static void check_poison_mem(unsigned char *mem, size_t bytes) if (!__ratelimit(&ratelimit)) return; else if (start == end && single_bit_flip(*start, PAGE_POISON)) pr_err("pagealloc: single bit error\n"); pr_err("pagealloc: single bit error on page with phys start 0x%lx\n", (unsigned long)page_to_phys(page)); else pr_err("pagealloc: memory corruption\n"); pr_err("pagealloc: memory corruption on page with phys start 0x%lx\n", (unsigned long)page_to_phys(page)); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, start, end - start + 1, 1); BUG_ON(PANIC_CORRUPTION); dump_stack(); } Loading @@ -104,7 +108,7 @@ static void unpoison_page(struct page *page) * that is freed to buddy. Thus no extra check is done to * see if a page was poisoned. */ check_poison_mem(addr, PAGE_SIZE); check_poison_mem(page, addr, PAGE_SIZE); kunmap_atomic(addr); } Loading