[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171130080325.24785-2-jslaby@suse.cz>
Date: Thu, 30 Nov 2017 09:03:25 +0100
From: Jiri Slaby <jslaby@...e.cz>
To: mingo@...hat.com
Cc: linux-kernel@...r.kernel.org, Jiri Slaby <jslaby@...e.cz>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Josh Poimboeuf <jpoimboe@...hat.com>
Subject: [PATCH 2/2] x86/stacktrace: make sure reliable stack trace reached userspace
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@...e.cz>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: x86@...nel.org
Cc: Josh Poimboeuf <jpoimboe@...hat.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
Powered by blists - more mailing lists