summaryrefslogtreecommitdiffstats
path: root/runtime/arch
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-04-03 02:17:06 -0700
committerAndreas Gampe <agampe@google.com>2015-04-03 02:23:35 -0700
commit9415886d879a7459ee9a3c6613f1a2687c87f08a (patch)
tree952b7416c50261309e78a6ae853f2536271a6357 /runtime/arch
parenta68a7cf8f3a6fef22d71a14350176115cb13857f (diff)
downloadart-9415886d879a7459ee9a3c6613f1a2687c87f08a.tar.gz
art-9415886d879a7459ee9a3c6613f1a2687c87f08a.tar.bz2
art-9415886d879a7459ee9a3c6613f1a2687c87f08a.zip
ART: Avoid obvious segfault in arm & x86 fault handler
These handlers need to read an instruction to determine where to look for info. Don't try to read from pc=0. Bug: 20040863 Change-Id: I38b56dc6dd806df22e608ee8d46c4091a738e4bc
Diffstat (limited to 'runtime/arch')
-rw-r--r--runtime/arch/arm/fault_handler_arm.cc7
-rw-r--r--runtime/arch/x86/fault_handler_x86.cc6
2 files changed, 13 insertions, 0 deletions
diff --git a/runtime/arch/arm/fault_handler_arm.cc b/runtime/arch/arm/fault_handler_arm.cc
index 325b283b83..3e8b36719e 100644
--- a/runtime/arch/arm/fault_handler_arm.cc
+++ b/runtime/arch/arm/fault_handler_arm.cc
@@ -95,6 +95,13 @@ void FaultManager::GetMethodAndReturnPcAndSp(siginfo_t* siginfo ATTRIBUTE_UNUSED
// Need to work out the size of the instruction that caused the exception.
uint8_t* ptr = reinterpret_cast<uint8_t*>(sc->arm_pc);
VLOG(signals) << "pc: " << std::hex << static_cast<void*>(ptr);
+
+ if (ptr == nullptr) {
+ // Somebody jumped to 0x0. Definitely not ours, and will definitely segfault below.
+ *out_method = nullptr;
+ return;
+ }
+
uint32_t instr_size = GetInstructionSize(ptr);
*out_return_pc = (sc->arm_pc + instr_size) | 1;
diff --git a/runtime/arch/x86/fault_handler_x86.cc b/runtime/arch/x86/fault_handler_x86.cc
index ad962e2e11..27a4adf032 100644
--- a/runtime/arch/x86/fault_handler_x86.cc
+++ b/runtime/arch/x86/fault_handler_x86.cc
@@ -275,6 +275,12 @@ void FaultManager::GetMethodAndReturnPcAndSp(siginfo_t* siginfo, void* context,
uint8_t* pc = reinterpret_cast<uint8_t*>(uc->CTX_EIP);
VLOG(signals) << HexDump(pc, 32, true, "PC ");
+ if (pc == nullptr) {
+ // Somebody jumped to 0x0. Definitely not ours, and will definitely segfault below.
+ *out_method = nullptr;
+ return;
+ }
+
uint32_t instr_size = GetInstructionSize(pc);
if (instr_size == 0) {
// Unknown instruction, tell caller it's not ours.