This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Intercept __tls_get_addr (except for PPC and S390X)
Needs RevisionPublic

Authored by thurston on May 2 2023, 3:58 PM.

Details

Summary

This ports sanitizer-common's __tls_get_addr interceptor to HWASan, since
HWASan does not include them.

This patch does not cover PowerPC and S390X. Although sanitizer-common
contains reference code, it needs to be adapted to HWASan, and I do not have
the setup to test it.

Diff Detail

Event Timeline

thurston created this revision.May 2 2023, 3:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 3:58 PM
thurston requested review of this revision.May 2 2023, 3:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 3:58 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

I assume this done for lsan? @kstoimenov

compiler-rt/lib/hwasan/hwasan_interceptors.cpp
308

we don't hwasan there

compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp
9–12

we don't hwasan there
set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})

vitalybuka accepted this revision.May 2 2023, 5:09 PM
This revision is now accepted and ready to land.May 2 2023, 5:09 PM
vitalybuka requested changes to this revision.May 2 2023, 5:12 PM

Let's not copy interceptors from common to hwasan.

compiler-rt/lib/hwasan/hwasan_interceptors.cpp
264
This revision now requires changes to proceed.May 2 2023, 5:12 PM

Can you try the following?

#include "hwasan_platform_interceptors.h"
#include "sanitizer_common/sanitizer_common_interceptors.inc"

then hwasan_platform_interceptors.h like:

#include "sanitizer_common/sanitizer_platform_interceptors.h"

#undef SANITIZER_INTERCEPT_STRLEN
...all of them without SANITIZER_INTERCEPT_TLS_GET_ADDR...
#undef SANITIZER_INTERCEPT_STRLEN

then

#define SANITIZER_INTERCEPT_STRLEN 0
...all of them without SANITIZER_INTERCEPT_TLS_GET_ADDR...
#define SANITIZER_INTERCEPT_STRLEN 0

Any progress here? we need more common interceptors, e.g. mmap

Any progress here? we need more common interceptors, e.g. mmap

Making it work with common interceptors (rather than specializing them to specific interceptors for HWASan) made it a bit more complicated. I'll take another stab at it, hopefully this week.