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

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