[Devel] [PATCH vz9 06/16] mm: issue panic() on bad page/pte bugs if panic_on_warn is set

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Wed Sep 29 10:00:07 MSK 2021


From: Andrey Ryabinin <aryabinin at virtuozzo.com>

Bad page state bugs is serious issue. It's worth issue panic if
panic_on_warn is set to collect crash dump and catch issue earlier.

https://jira.sw.ru/browse/PSBM-70168
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

Cherry-picked from vz8 commit 217a2f05be4d ("mm: issue panic() on bad
page/pte bugs if panic_on_warn is set")).

Added same conditional panic() calls to other paths where TAINT_BAD_PAGE
flag is being set.

Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 mm/filemap.c    | 2 ++
 mm/memory.c     | 2 ++
 mm/page_alloc.c | 2 ++
 mm/slab.c       | 2 ++
 mm/slub.c       | 6 ++++++
 5 files changed, 14 insertions(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index d1458ecf2f51..a5cedb2bce8b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -170,6 +170,8 @@ static void unaccount_page_cache_page(struct address_space *mapping,
 		dump_page(page, "still mapped when deleted");
 		dump_stack();
 		add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+		if (panic_on_warn)
+			panic("panic_on_warn set ...\n");
 
 		mapcount = page_mapcount(page);
 		if (mapping_exiting(mapping) &&
diff --git a/mm/memory.c b/mm/memory.c
index 4a687ad646b9..cb0ccb6af693 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -559,6 +559,8 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
 		 mapping ? mapping->a_ops->readpage : NULL);
 	dump_stack();
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 }
 
 /*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aae89d58046f..d056b407391f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -674,6 +674,8 @@ static void bad_page(struct page *page, const char *reason)
 	/* Leave bad fields for debug, except PageBuddy could make trouble */
 	page_mapcount_reset(page); /* remove PageBuddy */
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 }
 
 static inline unsigned int order_to_pindex(int migratetype, int order)
diff --git a/mm/slab.c b/mm/slab.c
index d0f725637663..2f8eade1476b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -443,6 +443,8 @@ static void __slab_error(const char *function, struct kmem_cache *cachep,
 	       function, cachep->name, msg);
 	dump_stack();
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 }
 #endif
 
diff --git a/mm/slub.c b/mm/slub.c
index f77d8cd79ef7..d4e098985615 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -775,6 +775,8 @@ void object_err(struct kmem_cache *s, struct page *page,
 	slab_bug(s, "%s", reason);
 	print_trailer(s, page, object);
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 }
 
 static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
@@ -793,6 +795,8 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
 	print_page_info(page);
 	dump_stack();
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 }
 
 static void init_object(struct kmem_cache *s, void *object, u8 val)
@@ -845,6 +849,8 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
 					fault[0], value);
 	print_trailer(s, page, object);
 	add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+	if (panic_on_warn)
+		panic("panic_on_warn set ...\n");
 
 skip_bug_print:
 	restore_bytes(s, what, value, fault, end);
-- 
2.30.2



More information about the Devel mailing list