Skip to content

Commit 1aabc59

Browse files
rostedttorvalds
authored andcommitted
x86: Fix dumpstack_64 to keep state of "used" variable in loop
Commit 2223f6f "x86: Clean up dumpstack_64.c code" moved the used variable to a local within the loop, but the in_exception_stack() depended on being non-volatile with the ability to change it. By always re-initializing the "used" variable to zero, it would cause the in_exception_stack() to return the same thing each time, and cause the dump_stack loop to go into an infinite loop. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b33ce44 commit 1aabc59

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎arch/x86/kernel/dumpstack_64.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,18 @@ enum stack_type {
115115
};
116116

117117
static enum stack_type
118-
analyze_stack(int cpu, struct task_struct *task,
119-
unsigned long *stack, unsigned long **stack_end, char **id)
118+
analyze_stack(int cpu, struct task_struct *task, unsigned long *stack,
119+
unsigned long **stack_end, unsigned *used, char **id)
120120
{
121121
unsigned long *irq_stack;
122122
unsigned long addr;
123-
unsigned used = 0;
124123

125124
addr = ((unsigned long)stack & (~(THREAD_SIZE - 1)));
126125
if ((unsigned long)task_stack_page(task) == addr)
127126
return STACK_IS_NORMAL;
128127

129128
*stack_end = in_exception_stack(cpu, (unsigned long)stack,
130-
&used, id);
129+
used, id);
131130
if (*stack_end)
132131
return STACK_IS_EXCEPTION;
133132

@@ -158,6 +157,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
158157
struct thread_info *tinfo;
159158
unsigned long *irq_stack;
160159
unsigned long dummy;
160+
unsigned used = 0;
161161
int graph = 0;
162162
int done = 0;
163163

@@ -186,7 +186,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
186186
enum stack_type stype;
187187
char *id;
188188

189-
stype = analyze_stack(cpu, task, stack, &stack_end, &id);
189+
stype = analyze_stack(cpu, task, stack, &stack_end, &used, &id);
190190

191191
/* Default finish unless specified to continue */
192192
done = 1;

0 commit comments

Comments
 (0)