mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-26 17:25:04 +01:00
Use general instruction/stack pointer convenience method instead of manually
finding the instruction/stack pointer for exploitability rating. There was already a method that found the instruction pointer, so the files for exploitability ratings had repeated code. Also a method for finding the stack pointer is implemented in this CL. R=ivanpe@chromium.org Review URL: https://codereview.chromium.org/1210943005 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1468 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
12213a5e15
commit
e2eb4505d0
7 changed files with 74 additions and 33 deletions
|
|
@ -185,6 +185,49 @@ bool DumpContext::GetInstructionPointer(uint64_t* ip) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DumpContext::GetStackPointer(uint64_t* sp) const {
|
||||
BPLOG_IF(ERROR, !sp) << "DumpContext::GetStackPointer requires |sp|";
|
||||
assert(sp);
|
||||
*sp = 0;
|
||||
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid DumpContext for GetStackPointer";
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (GetContextCPU()) {
|
||||
case MD_CONTEXT_AMD64:
|
||||
*sp = GetContextAMD64()->rsp;
|
||||
break;
|
||||
case MD_CONTEXT_ARM:
|
||||
*sp = GetContextARM()->iregs[MD_CONTEXT_ARM_REG_SP];
|
||||
break;
|
||||
case MD_CONTEXT_ARM64:
|
||||
*sp = GetContextARM64()->iregs[MD_CONTEXT_ARM64_REG_SP];
|
||||
break;
|
||||
case MD_CONTEXT_PPC:
|
||||
*sp = GetContextPPC()->gpr[MD_CONTEXT_PPC_REG_SP];
|
||||
break;
|
||||
case MD_CONTEXT_PPC64:
|
||||
*sp = GetContextPPC64()->gpr[MD_CONTEXT_PPC64_REG_SP];
|
||||
break;
|
||||
case MD_CONTEXT_SPARC:
|
||||
*sp = GetContextSPARC()->g_r[MD_CONTEXT_SPARC_REG_SP];
|
||||
break;
|
||||
case MD_CONTEXT_X86:
|
||||
*sp = GetContextX86()->esp;
|
||||
break;
|
||||
case MD_CONTEXT_MIPS:
|
||||
*sp = GetContextMIPS()->iregs[MD_CONTEXT_MIPS_REG_SP];
|
||||
break;
|
||||
default:
|
||||
// This should never happen.
|
||||
BPLOG(ERROR) << "Unknown CPU architecture in GetStackPointer";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DumpContext::SetContextFlags(uint32_t context_flags) {
|
||||
context_flags_ = context_flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
#include "processor/exploitability_linux.h"
|
||||
|
||||
#include "google_breakpad/common/minidump_exception_linux.h"
|
||||
#include "google_breakpad/processor/process_state.h"
|
||||
#include "google_breakpad/processor/call_stack.h"
|
||||
#include "google_breakpad/processor/process_state.h"
|
||||
#include "google_breakpad/processor/stack_frame.h"
|
||||
#include "processor/logging.h"
|
||||
|
||||
|
|
@ -98,26 +98,9 @@ ExploitabilityRating ExploitabilityLinux::CheckPlatformExploitability() {
|
|||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
// Getting instruction pointer based off architecture.
|
||||
uint32_t architecture = context->GetContextCPU();
|
||||
switch (architecture) {
|
||||
case MD_CONTEXT_X86:
|
||||
instruction_ptr = context->GetContextX86()->eip;
|
||||
break;
|
||||
case MD_CONTEXT_AMD64:
|
||||
instruction_ptr = context->GetContextAMD64()->rip;
|
||||
break;
|
||||
case MD_CONTEXT_ARM:
|
||||
instruction_ptr =
|
||||
context->GetContextARM()->iregs[MD_CONTEXT_ARM_REG_PC];
|
||||
break;
|
||||
case MD_CONTEXT_ARM64:
|
||||
instruction_ptr =
|
||||
context->GetContextARM64()->iregs[MD_CONTEXT_ARM64_REG_PC];
|
||||
break;
|
||||
default:
|
||||
BPLOG(INFO) << "Unsupported architecture.";
|
||||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
// Getting the instruction pointer.
|
||||
if (!context->GetInstructionPointer(&instruction_ptr)) {
|
||||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
// Checking for the instruction pointer in a valid instruction region.
|
||||
|
|
|
|||
|
|
@ -106,18 +106,14 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() {
|
|||
uint64_t stack_ptr = 0;
|
||||
uint64_t instruction_ptr = 0;
|
||||
|
||||
switch (context->GetContextCPU()) {
|
||||
case MD_CONTEXT_X86:
|
||||
stack_ptr = context->GetContextX86()->esp;
|
||||
instruction_ptr = context->GetContextX86()->eip;
|
||||
break;
|
||||
case MD_CONTEXT_AMD64:
|
||||
stack_ptr = context->GetContextAMD64()->rsp;
|
||||
instruction_ptr = context->GetContextAMD64()->rip;
|
||||
break;
|
||||
default:
|
||||
BPLOG(INFO) << "Unsupported architecture.";
|
||||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
// Getting the instruction pointer.
|
||||
if (!context->GetInstructionPointer(&instruction_ptr)) {
|
||||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
// Getting the stack pointer.
|
||||
if (!context->GetStackPointer(&stack_ptr)) {
|
||||
return EXPLOITABILITY_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
// Check if we are executing on the stack.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue