Verify that the elf matches the expected arch.
To avoid a case where a malicious app might try and trick the system to
create an elf and register object that mismatches, always verify that they
are the same arch.
Test: Ran unit tests.
Change-Id: I66978e9e02f8e4f396856912e7019528ead4838e
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index b8b0ac6..b3c5549 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -135,6 +135,8 @@
last_error_.code = ERROR_NONE;
last_error_.address = 0;
+ ArchEnum arch = regs_->Arch();
+
bool return_address_attempt = false;
bool adjust_pc = false;
std::unique_ptr<JitDebug> jit_debug;
@@ -155,7 +157,7 @@
if (ShouldStop(map_suffixes_to_ignore, map_info->name)) {
break;
}
- elf = map_info->GetElf(process_memory_);
+ elf = map_info->GetElf(process_memory_, arch);
step_pc = regs_->pc();
rel_pc = elf->GetRelPc(step_pc, map_info);
// Everyone except elf data in gdb jit debug maps uses the relative pc.