Skip to content

Commit cbf5b73

Browse files
EtsukataKAGA-KOKO
authored andcommitted
x86/stacktrace: Prevent infinite loop in arch_stack_walk_user()
arch_stack_walk_user() checks `if (fp == frame.next_fp)` to prevent a infinite loop by self reference but it's not enogh for circular reference. Once a lack of return address is found, there is no point to continue the loop, so break out. Fixes: 02b6751 ("tracing: add support for userspace stacktraces in tracing/iter_ctrl") Signed-off-by: Eiichi Tsukata <devel@etsukata.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lkml.kernel.org/r/20190711023501.963-1-devel@etsukata.com
1 parent 7652ac9 commit cbf5b73

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎arch/x86/kernel/stacktrace.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
129129
break;
130130
if ((unsigned long)fp < regs->sp)
131131
break;
132-
if (frame.ret_addr) {
133-
if (!consume_entry(cookie, frame.ret_addr, false))
134-
return;
135-
}
136-
if (fp == frame.next_fp)
132+
if (!frame.ret_addr)
133+
break;
134+
if (!consume_entry(cookie, frame.ret_addr, false))
137135
break;
138136
fp = frame.next_fp;
139137
}

0 commit comments

Comments
 (0)