diff options
author | Liu.andrew.x@gmail.com <Liu.andrew.x@gmail.com> | 2015-07-16 20:42:29 +0000 |
---|---|---|
committer | Liu.andrew.x@gmail.com <Liu.andrew.x@gmail.com> | 2015-07-16 20:42:29 +0000 |
commit | a840e1b710f3a24ff47d300425cf9bf5b5573a5c (patch) | |
tree | 47699daaa861dabb3030dba1d7ad3d16699296c0 /src/processor/exploitability_linux.h | |
parent | Fix -Wreorder warnings in the Windows code. (diff) | |
download | breakpad-a840e1b710f3a24ff47d300425cf9bf5b5573a5c.tar.xz |
Add ELF header analysis when checking for instruction pointer in code.
If the minidump module containing the instruction pointer has memory
containing the ELF header and program header table, when checking the
exploitability rating, the processor will use the ELF header data to determine
if the instruction pointer lies in an executable region of the module, rather
than just checking if it lies in a module.
R=ivanpe@chromium.org
Review URL: https://codereview.chromium.org/1233973002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1472 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/processor/exploitability_linux.h')
-rw-r--r-- | src/processor/exploitability_linux.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/processor/exploitability_linux.h b/src/processor/exploitability_linux.h index 42f9bc52..2deb4991 100644 --- a/src/processor/exploitability_linux.h +++ b/src/processor/exploitability_linux.h @@ -37,11 +37,23 @@ #ifndef GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_LINUX_H_ #define GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_LINUX_H_ +#include "common/scoped_ptr.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/exploitability.h" namespace google_breakpad { +enum LinuxArchitectureType { + // A 32-bit Linux architecture. + LINUX_32_BIT, + + // A 64-bit Linux architecture. + LINUX_64_BIT, + + // Some other architecture that is not Linux. + UNSUPPORTED_ARCHITECTURE +}; + class ExploitabilityLinux : public Exploitability { public: ExploitabilityLinux(Minidump *dump, @@ -57,6 +69,46 @@ class ExploitabilityLinux : public Exploitability { // This method checks the exception that triggered the creation of the // minidump and reports whether the exception suggests no exploitability. bool BenignCrashTrigger(const MDRawExceptionStream *raw_exception_stream); + + // Checks if the minidump architecture is 32-bit or 64-bit. + LinuxArchitectureType ArchitectureType(); + + // Loads ELF header data of the module present in the given memory + // region into the scoped pointer. + // This method takes a scoped pointer in which the ELF header data is + // loaded, the memory region containing the ELF header, and the base + // address of the ELF header. + template<typename T> + void LoadElfHeader(MinidumpMemoryRegion *memory, + uint64_t base_address, + T *header) { + for (size_t i = 0; i < sizeof(T); i++) { + uint8_t my_byte = 0; + memory->GetMemoryAtAddress(base_address + i, &my_byte); + *(reinterpret_cast<char *>(header) + i) = my_byte; + } + } + + // Loads the Program Header Table of the module present in the given + // memory region into the scoped array. + // This method takes a scoped array in which the header table data is + // loaded, the memory region containing the table, the base address of + // the program header table, and the number of entries in the table. + template<typename T> + void LoadElfHeaderTable(MinidumpMemoryRegion *memory, + uint64_t base_address, + uint16_t e_phnum, + T table[]) { + uint64_t offset = 0; + for (size_t i = 0; i < e_phnum; i++) { + T *entry = &table[i]; + for (size_t j = 0; j < sizeof(T); j++) { + uint8_t my_byte = 0; + memory->GetMemoryAtAddress(base_address + offset++, &my_byte); + *(reinterpret_cast<char *>(entry) + j) = my_byte; + } + } + } }; } // namespace google_breakpad |