Blame SOURCES/0004-Fix-for-bt-v-option-to-display-the-stack-end-address.patch

e039e7
From 1706f8b6ab50cd25e8fdabe8d50a37ce89bd60e0 Mon Sep 17 00:00:00 2001
e039e7
From: Lianbo Jiang <lijiang@redhat.com>
e039e7
Date: Thu, 6 Jan 2022 12:01:17 +0800
e039e7
Subject: [PATCH 04/11] Fix for "bt -v" option to display the stack-end address
e039e7
 correctly
e039e7
e039e7
The "bt -v" command prints incorrect stack-end address when the
e039e7
"CONFIG_THREAD_INFO_IN_TASK=y" is enabled in kernel, the "bt -v"
e039e7
command output shows that the value stored at 0xffff8dee0312c198
e039e7
is 0xffffffffc076400a, however, the value stored actually at
e039e7
0xffff8dee0312c198 is NULL(0x0000000000000000), the stack-end
e039e7
address is incorrect.
e039e7
e039e7
Without the patch:
e039e7
crash> bt -v
e039e7
PID: 28642  TASK: ffff8dee0312c180  CPU: 0   COMMAND: "insmod"
e039e7
  possible stack overflow: ffff8dee0312c198: ffffffffc076400a != STACK_END_MAGIC
e039e7
                                             ^^^^^^^^^^^^^^^^
e039e7
e039e7
crash> rd 0xffff8dee0312c198
e039e7
ffff8dee0312c198:  0000000000000000                    ........
e039e7
                   ^^^^^^^^^^^^^^^^
e039e7
e039e7
With the patch:
e039e7
crash> bt -v
e039e7
PID: 28642  TASK: ffff8dee0312c180  CPU: 0   COMMAND: "insmod"
e039e7
  possible stack overflow: ffff991340bc0000: ffffffffc076400a != STACK_END_MAGIC
e039e7
e039e7
crash> rd 0xffff991340bc0000
e039e7
ffff991340bc0000:  ffffffffc076400a                    .@v.....
e039e7
e039e7
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
e039e7
---
e039e7
 task.c | 10 ++++++++--
e039e7
 1 file changed, 8 insertions(+), 2 deletions(-)
e039e7
e039e7
diff --git a/task.c b/task.c
e039e7
index bb6a5da8ad33..b5ddc88e0acb 100644
e039e7
--- a/task.c
e039e7
+++ b/task.c
e039e7
@@ -11202,7 +11202,7 @@ check_stack_overflow(void)
e039e7
 {
e039e7
 	int i, overflow, cpu_size, cpu, total;
e039e7
 	char buf[BUFSIZE];
e039e7
-	ulong magic, task, stackbase;
e039e7
+	ulong magic, task, stackbase, location;
e039e7
 	struct task_context *tc;
e039e7
 
e039e7
 	if (!tt->stack_end_magic && 
e039e7
@@ -11286,9 +11286,15 @@ check_stack_end_magic:
e039e7
 		if (magic != STACK_END_MAGIC) {
e039e7
 			if (!overflow)
e039e7
 				print_task_header(fp, tc, 0);
e039e7
+
e039e7
+			if (tt->flags & THREAD_INFO_IN_TASK)
e039e7
+				location = task_to_stackbase(tc->task);
e039e7
+			else
e039e7
+				location = tc->thread_info + SIZE(thread_info);
e039e7
+
e039e7
 			fprintf(fp, 
e039e7
 			    "  possible stack overflow: %lx: %lx != STACK_END_MAGIC\n",
e039e7
-				tc->thread_info + SIZE(thread_info), magic);
e039e7
+				location, magic);
e039e7
 			overflow++, total++;
e039e7
 		}
e039e7
 
e039e7
-- 
e039e7
2.20.1
e039e7