From: Matt Redfearn <matt.redfearn@imgtec.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: <linux-mips@linux-mips.org>,
Matt Redfearn <matt.redfearn@imgtec.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] MIPS: Stacktrace: Fix __usermode() of uninitialised regs
Date: Tue, 28 Feb 2017 15:37:57 +0000 [thread overview]
Message-ID: <1488296279-23057-4-git-send-email-matt.redfearn@imgtec.com> (raw)
In-Reply-To: <1488296279-23057-1-git-send-email-matt.redfearn@imgtec.com>
Commit 81a76d7119f6 ("MIPS: Avoid using unwind_stack() with usermode")
added a check if the passed regs are from user mode, and perform a raw
backtrace if so.
When WARN() is invoked, __dump_stack calls show_stack()
with NULL task and stack pointers. This leads show_stack to create a
pt_regs struct on the stack, and initialise it via prepare_frametrace().
When show_backtrace() examines the regs, the value of the status
register checked by user_mode() is unpredictable, depending on the
uninitialised content of the stack. This leads to show_backtrace()
sometimes showing raw backtraces instead of correctly walking the kernel
stack.
Fix this by initialising the contents of the saved status register in
prepare_frametrace().
Fixes: 81a76d7119f6 ("MIPS: Avoid using unwind_stack() with usermode")
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---
arch/mips/include/asm/stacktrace.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/mips/include/asm/stacktrace.h b/arch/mips/include/asm/stacktrace.h
index 780ee2c2a2ac..4845945d02a5 100644
--- a/arch/mips/include/asm/stacktrace.h
+++ b/arch/mips/include/asm/stacktrace.h
@@ -1,6 +1,7 @@
#ifndef _ASM_STACKTRACE_H
#define _ASM_STACKTRACE_H
+#include <asm/asm.h>
#include <asm/ptrace.h>
#ifdef CONFIG_KALLSYMS
@@ -47,6 +48,8 @@ static __always_inline void prepare_frametrace(struct pt_regs *regs)
: "=m" (regs->cp0_epc),
"=m" (regs->regs[29]), "=m" (regs->regs[31])
: : "memory");
+ /* show_backtrace behaviour depends on user_mode(regs) */
+ regs->cp0_status = read_c0_status();
}
#endif /* _ASM_STACKTRACE_H */
--
2.7.4
next prev parent reply other threads:[~2017-03-01 7:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 15:37 [PATCH 0/4] MIPS: Further microMIPS stack unwinding fixes Matt Redfearn
2017-02-28 15:37 ` [PATCH 1/4] MIPS: Handle non word sized instructions when examining frame Matt Redfearn
2017-02-28 20:54 ` Maciej W. Rozycki
2017-03-01 13:47 ` Matt Redfearn
2017-02-28 15:37 ` [PATCH 2/4] MIPS: microMIPS: Fix decoding of addiusp instruction Matt Redfearn
2017-02-28 22:04 ` Maciej W. Rozycki
2017-03-01 13:51 ` Matt Redfearn
2017-02-28 15:37 ` Matt Redfearn [this message]
2017-02-28 15:37 ` [PATCH 4/4] MIPS: microMIPS: Fix decoding of swsp16 instruction Matt Redfearn
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=1488296279-23057-4-git-send-email-matt.redfearn@imgtec.com \
--to=matt.redfearn@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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®