[ASan] Do not misrepresent high value address dereferences as null dereferences
authorJulian Lettner <jlettner@apple.com>
Thu, 10 Oct 2019 00:33:04 +0000 (00:33 +0000)
committerJulian Lettner <jlettner@apple.com>
Thu, 10 Oct 2019 00:33:04 +0000 (00:33 +0000)
commitb577efe4567f1f6a711ad36e1d17280dd1c4f009
treedb99143a2af9841c57ec159ee2e0ef5dda26869a
parentd6e9e99cec95c83293c68d3b30534e34f53a1923
[ASan] Do not misrepresent high value address dereferences as null dereferences

Dereferences with addresses above the 48-bit hardware addressable range
produce "invalid instruction" (instead of "invalid access") hardware
exceptions (there is no hardware address decoding logic for those bits),
and the address provided by this exception is the address of the
instruction (not the faulting address).  The kernel maps the "invalid
instruction" to SEGV, but fails to provide the real fault address.

Because of this ASan lies and says that those cases are null
dereferences.  This downgrades the severity of a found bug in terms of
security.  In the ASan signal handler, we can not provide the real
faulting address, but at least we can try not to lie.

rdar://50366151

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D68676

llvm-svn: 374265
compiler-rt/lib/asan/asan_errors.h
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c [new file with mode: 0644]