Hwasan reporting check for dladdr failing
authorMatthew Malcomson <matthew.malcomson@arm.com>
Thu, 12 Nov 2020 12:37:36 +0000 (12:37 +0000)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 16 Nov 2020 12:25:27 +0000 (12:25 +0000)
commit83ac18205ec69a00ac2be3b603bc3a61293fbe89
treed84e4492f06e79d0fe970f5f20b63cee81c56cf2
parent6c185acfffc1f7cdf2a6e785cb4a422140c34f06
Hwasan reporting check for dladdr failing

In `GetGlobalSizeFromDescriptor` we use `dladdr` to get info on the the
current address.  `dladdr` returns 0 if it failed.
During testing on Linux this returned 0 to indicate failure, and
populated the `info` structure with a NULL pointer which was
dereferenced later.

This patch checks for `dladdr` returning 0, and in that case returns 0
from `GetGlobalSizeFromDescriptor` to indicate failure of identifying
the address.

This occurs when `GetModuleNameAndOffsetForPC` succeeds for some address
not in a dynamically loaded library.  One example is when the found
"module" is '[stack]' having come from parsing /proc/self/maps.

Differential Revision: https://reviews.llvm.org/D91344
compiler-rt/lib/hwasan/hwasan_report.cpp