[Crash-utility] [PATCH] x86_64: do not process zero size exception stack

Alexey Makhalov amakhalov at vmware.com
Tue Nov 3 23:47:01 UTC 2020


There is an issue with newer Linux kernel (found on 5.9.y)
where 'bt 0' fails with:
  crash> bt 0
  PID: 0      TASK: ffffffff95414900  CPU: 0   COMMAND: "swapper/0"
  bt: invalid size request: 0  type: "stack contents"
  bt: read of stack at fffffe0000012000 failed

The reason is: readmem fails to read content of exception
stack [4]. As you can see it has correct base: fffffe0000012000,
but zero size, See reduced output of 'help -m':
                  stkinfo: isize: 16384
                           esize[7]: 4096,4096,4096,4096,0,0,0
                           NMI_stack_index: 1
                           exception_stacks:
                             [0]: DOUBLEFAULT
                             [1]: NMI
                             [2]: DEBUG
                             [3]: MCE
                             [4]: (unknown)
                             [5]: (unknown)
                             [6]: (unknown)
                           ebase[cpus][7]:
   [0]: fffffe0000009000 fffffe000000b000 fffffe000000d000 fffffe000000f000
        fffffe0000012000 0000000000000000 0000000000000000

>From https://www.kernel.org/doc/Documentation/x86/kernel-stacks
there are only 4 exception stacks for x86. So I'm not sure what
5th ebase ([4]) is, but its size is zero, (guard page?)
So, solution I use here is to ignore exception stack if its size
is zero.

Signed-off-by: Alexey Makhalov <amakhalov at vmware.com>
---
 x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86_64.c b/x86_64.c
index fc05e8a..a8c9b2e 100644
--- a/x86_64.c
+++ b/x86_64.c
@@ -5090,7 +5090,7 @@ skip_stage:
                 	ms->stkinfo.esize[estack];
 		console("x86_64_get_dumpfile_stack_frame: searching %s estack at %lx\n", 
 			ms->stkinfo.exception_stacks[estack], bt->stackbase);
-		if (!(bt->stackbase)) 
+		if (!(bt->stackbase) || !(ms->stkinfo.esize[estack]))
 			goto skip_stage;
 		bt->stackbuf = ms->irqstack;
 		alter_stackbuf(bt);
-- 
2.11.0




More information about the Crash-utility mailing list