[GWP-ASan] Handle wild touches of the guarded pool.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Tue, 28 Feb 2023 22:05:42 +0000 (14:05 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Tue, 28 Feb 2023 22:05:51 +0000 (14:05 -0800)
commitbc949f923ee37e6c71b69d0c0337d0e6b499832d
tree9ccc238660b728bd1c1861943de1cae792370722
parentece0b96979c88bab9ec6c53b4d59f7c4b1dce017
[GWP-ASan] Handle wild touches of the guarded pool.

AllocMeta could be null when returned from __gwp_asan_get_metadata() for
a bad access into the GuardedPagePool that was never allocated.
Currently, then we dereference the null pointer, oops.

Hoist the check up and print a message (only once in recoverable mode)
about the bad memory access.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D144973
compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp
compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
compiler-rt/lib/gwp_asan/tests/backtrace.cpp
compiler-rt/lib/gwp_asan/tests/harness.cpp
compiler-rt/lib/gwp_asan/tests/harness.h
compiler-rt/lib/gwp_asan/tests/never_allocated.cpp [new file with mode: 0644]
compiler-rt/lib/gwp_asan/tests/recoverable.cpp