From: Eiichi Tsukata <devel@etsukata.com>
To: tglx@linutronix.de, peterz@infradead.org,
torvalds@linux-foundation.org, rostedt@goodmis.org,
jpoimboe@redhat.com, mingo@redhat.com, bp@alien8.de,
hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Eiichi Tsukata <devel@etsukata.com>
Subject: [PATCH] x86/stacktrace: Fix infinite loop in arch_stack_walk_user()
Date: Thu, 11 Jul 2019 11:35:01 +0900 [thread overview]
Message-ID: <20190711023501.963-1-devel@etsukata.com> (raw)
Current arch_stack_walk_user() checks `if (fp == frame.next_fp)`
to prevent infinite loop by self reference but it's not enogh for
circular reference.
Once we find a lack of return address, there is no need to continue
loop, so let's break out.
Fixes: 02b67518e2b1 ("tracing: add support for userspace stacktraces in tracing/iter_ctrl")
Signed-off-by: Eiichi Tsukata <devel@etsukata.com>
---
arch/x86/kernel/stacktrace.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 2abf27d7df6b..b1a1f4b4c943 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -129,11 +129,8 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
break;
if ((unsigned long)fp < regs->sp)
break;
- if (frame.ret_addr) {
- if (!consume_entry(cookie, frame.ret_addr, false))
- return;
- }
- if (fp == frame.next_fp)
+ if (!frame.ret_addr ||
+ !consume_entry(cookie, frame.ret_addr, false))
break;
fp = frame.next_fp;
}
--
2.21.0
next reply other threads:[~2019-07-11 2:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 2:35 Eiichi Tsukata [this message]
2019-07-11 4:10 ` [PATCH] x86/stacktrace: Fix infinite loop in arch_stack_walk_user() Linus Torvalds
2019-07-11 6:25 ` [tip:x86/urgent] x86/stacktrace: Prevent " tip-bot for Eiichi Tsukata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190711023501.963-1-devel@etsukata.com \
--to=devel@etsukata.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).