Skip to content

Commit fa33215

Browse files
amlutosuryasaimadhu
authored andcommitted
x86/dumpstack: Fix off-by-one errors in stack identification
The get_stack_info() function is off-by-one when checking whether an address is on a IRQ stack or a IST stack. This prevents an overflowed IRQ or IST stack from being dumped properly. [ tglx: Do the same for 32-bit ] Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: x86-ml <x86@kernel.org> Link: https://lkml.kernel.org/r/20190414160143.785651055@linutronix.de
1 parent 7dbcf2b commit fa33215

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎arch/x86/kernel/dumpstack_32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static bool in_hardirq_stack(unsigned long *stack, struct stack_info *info)
4141
* This is a software stack, so 'end' can be a valid stack pointer.
4242
* It just means the stack is empty.
4343
*/
44-
if (stack <= begin || stack > end)
44+
if (stack < begin || stack > end)
4545
return false;
4646

4747
info->type = STACK_TYPE_IRQ;
@@ -66,7 +66,7 @@ static bool in_softirq_stack(unsigned long *stack, struct stack_info *info)
6666
* This is a software stack, so 'end' can be a valid stack pointer.
6767
* It just means the stack is empty.
6868
*/
69-
if (stack <= begin || stack > end)
69+
if (stack < begin || stack > end)
7070
return false;
7171

7272
info->type = STACK_TYPE_SOFTIRQ;

‎arch/x86/kernel/dumpstack_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static bool in_exception_stack(unsigned long *stack, struct stack_info *info)
6565
begin = end - (exception_stack_sizes[k] / sizeof(long));
6666
regs = (struct pt_regs *)end - 1;
6767

68-
if (stack <= begin || stack >= end)
68+
if (stack < begin || stack >= end)
6969
continue;
7070

7171
info->type = STACK_TYPE_EXCEPTION + k;
@@ -88,7 +88,7 @@ static bool in_irq_stack(unsigned long *stack, struct stack_info *info)
8888
* This is a software stack, so 'end' can be a valid stack pointer.
8989
* It just means the stack is empty.
9090
*/
91-
if (stack <= begin || stack > end)
91+
if (stack < begin || stack >= end)
9292
return false;
9393

9494
info->type = STACK_TYPE_IRQ;

0 commit comments

Comments
 (0)