The "bt -v" command prints incorrect stack-end address when the
"CONFIG_THREAD_INFO_IN_TASK=y" is enabled in kernel, the "bt -v"
command output shows that the value stored at 0xffff8dee0312c198
is 0xffffffffc076400a, however, the value stored actually at
0xffff8dee0312c198 is NULL(0x0000000000000000), the stack-end
address is incorrect.

Without the patch:
crash> bt -v
PID: 28642  TASK: ffff8dee0312c180  CPU: 0   COMMAND: "insmod"
  possible stack overflow: ffff8dee0312c198: ffffffffc076400a != STACK_END_MAGIC
                                             ^^^^^^^^^^^^^^^^

crash> rd 0xffff8dee0312c198
ffff8dee0312c198:  0000000000000000                    ........
                   ^^^^^^^^^^^^^^^^

With the patch:
crash> bt -v
PID: 28642  TASK: ffff8dee0312c180  CPU: 0   COMMAND: "insmod"
  possible stack overflow: ffff991340bc0000: ffffffffc076400a != STACK_END_MAGIC

crash> rd 0xffff991340bc0000
ffff991340bc0000:  ffffffffc076400a                    .@v.....

Signed-off-by: Lianbo Jiang <[email protected]>
---
 task.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/task.c b/task.c
index bb6a5da8ad33..b5ddc88e0acb 100644
--- a/task.c
+++ b/task.c
@@ -11202,7 +11202,7 @@ check_stack_overflow(void)
 {
        int i, overflow, cpu_size, cpu, total;
        char buf[BUFSIZE];
-       ulong magic, task, stackbase;
+       ulong magic, task, stackbase, location;
        struct task_context *tc;
 
        if (!tt->stack_end_magic && 
@@ -11286,9 +11286,15 @@ check_stack_end_magic:
                if (magic != STACK_END_MAGIC) {
                        if (!overflow)
                                print_task_header(fp, tc, 0);
+
+                       if (tt->flags & THREAD_INFO_IN_TASK)
+                               location = task_to_stackbase(tc->task);
+                       else
+                               location = tc->thread_info + SIZE(thread_info);
+
                        fprintf(fp, 
                            "  possible stack overflow: %lx: %lx != 
STACK_END_MAGIC\n",
-                               tc->thread_info + SIZE(thread_info), magic);
+                               location, magic);
                        overflow++, total++;
                }
 
-- 
2.20.1

--
Crash-utility mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/crash-utility

Reply via email to