diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2019-01-23 21:59:54 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-03 12:45:32 +0000 |
commit | 8cf8a0d424584d8d3e7e29c3ea7864617498f16b (patch) | |
tree | 1e84e42ce4fe4ea54d8f30f5174ac0abca6c22a4 | |
parent | 4af511bad9827fd8a2e6bf925ccfbcb1276a4f6f (diff) |
Validate base mapping before using it
Prevent infinite looping when we access a stale base map. This
could happen when we encounter bogus mmap lists as happens in
https://github.com/KDAB/hotspot/issues/164
Verify that the base map actually corresponds to the expected
elf map and only use that then. Otherwise don't use the base
map and continue with the original mapping, hoping for the best.
While this fixes the stack overflow of the initial bug report,
it doesn't solve the fundamental issue of dealing with broken
data... We'll have to figure that one out separately.
Fixes: https://github.com/KDAB/hotspot/issues/164
Change-Id: Iaebddbfbc891784a7fcc05df47aba761b75cc587
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r-- | app/perfsymboltable.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index 27d0d58..ddb67f9 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -500,8 +500,12 @@ Dwfl_Module *PerfSymbolTable::module(quint64 addr, const PerfElfMap::ElfInfo &el if (!m_dwfl) return nullptr; - if (elf.pgoff && elf.hasBaseAddr()) - return module(addr, m_elfs.findElf(elf.baseAddr)); + if (elf.pgoff && elf.hasBaseAddr()) { + const auto base = m_elfs.findElf(elf.baseAddr); + if (base.addr == elf.baseAddr && !base.pgoff && elf.originalPath == base.originalPath) + return module(addr, base); + qWarning() << "stale base mapping referenced:" << elf << base << dec << m_pid << hex << addr; + } Dwfl_Module *mod = dwfl_addrmodule(m_dwfl, addr); |