From: Jiri Slaby <jslaby@suse.cz>
To: mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Jiri Slaby <jslaby@suse.cz>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH 2/2] x86/stacktrace: make sure reliable stack trace reached userspace
Date: Thu, 30 Nov 2017 09:03:25 +0100 [thread overview]
Message-ID: <20171130080325.24785-2-jslaby@suse.cz> (raw)
In-Reply-To: <20171130080325.24785-1-jslaby@suse.cz>
Make sure that save_stack_trace_reliable reached userspace when saying
"this stack trace is reliable."
Place this check only after stack unwinding error check, so that the
stack is printed if something really went wrong during unwinding.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
---
arch/x86/kernel/stacktrace.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 221a03e251bb..2153aff1b459 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -98,6 +98,7 @@ __save_stack_trace_reliable(struct stack_trace *trace,
struct unwind_state state;
struct pt_regs *regs;
unsigned long addr;
+ bool reached_user = false;
for (unwind_start(&state, task, NULL, NULL); !unwind_done(&state);
unwind_next_frame(&state)) {
@@ -117,6 +118,7 @@ __save_stack_trace_reliable(struct stack_trace *trace,
STACKTRACE_DUMP_ONCE(task);
return -EINVAL;
}
+ reached_user = true;
break;
}
@@ -142,6 +144,9 @@ __save_stack_trace_reliable(struct stack_trace *trace,
return -EINVAL;
}
+ if (!reached_user)
+ return -EINVAL;
+
if (trace->nr_entries < trace->max_entries)
trace->entries[trace->nr_entries++] = ULONG_MAX;
--
2.15.0
next prev parent reply other threads:[~2017-11-30 8:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 8:03 [PATCH 1/2] x86/stacktrace: do not fail when regs on stack for ORC Jiri Slaby
2017-11-30 8:03 ` Jiri Slaby [this message]
2017-11-30 19:57 ` Josh Poimboeuf
2017-11-30 19:59 ` Josh Poimboeuf
2017-12-01 7:34 ` Jiri Slaby
2017-12-14 21:58 ` Jiri Slaby
2017-12-18 3:37 ` Josh Poimboeuf
2017-12-18 6:59 ` Jiri Slaby
2017-12-20 17:45 ` Josh Poimboeuf
2017-12-20 19:07 ` Jiri Slaby
2018-04-16 22:16 ` Josh Poimboeuf
2018-04-19 13:42 ` Josh Poimboeuf
2018-05-10 12:33 ` Jiri Slaby
2018-05-10 12:49 ` Josh Poimboeuf
2018-05-11 7:01 ` Jiri Slaby
2018-05-11 15:12 ` Josh Poimboeuf
2018-05-14 11:08 ` Jiri Slaby
2018-05-14 13:42 ` Josh Poimboeuf
2018-05-14 14:00 ` Jiri Slaby
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=20171130080325.24785-2-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®