mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Patch getauxval for tsan re-exec
This commit is contained in:
parent
7fedc0ffbe
commit
f2e83f092d
@ -18,6 +18,16 @@ if (GLIBC_COMPATIBILITY)
|
|||||||
message (FATAL_ERROR "glibc_compatibility can only be used on x86_64 or aarch64.")
|
message (FATAL_ERROR "glibc_compatibility can only be used on x86_64 or aarch64.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (SANITIZE STREQUAL thread)
|
||||||
|
# Disable TSAN instrumentation that conflicts with re-exec due to high ASLR entropy using getauxval
|
||||||
|
# See longer comment in __auxv_init_procfs
|
||||||
|
# In the case of tsan we need to make sure getauxval is not instrumented as that would introduce tsan
|
||||||
|
# internal calls to functions that depend on a state that isn't initialized yet
|
||||||
|
set_source_files_properties(
|
||||||
|
musl/getauxval.c
|
||||||
|
PROPERTIES COMPILE_FLAGS "-mllvm -tsan-instrument-func-entry-exit=false")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Need to omit frame pointers to match the performance of glibc
|
# Need to omit frame pointers to match the performance of glibc
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ static unsigned long NO_SANITIZE_THREAD __auxv_init_procfs(unsigned long type)
|
|||||||
/// most global variables aren't initialized or available yet, so we can't initiate the auxiliary vector.
|
/// most global variables aren't initialized or available yet, so we can't initiate the auxiliary vector.
|
||||||
/// Normal glibc / musl getauxval doesn't have this problem since they initiate their auxval vector at the very
|
/// Normal glibc / musl getauxval doesn't have this problem since they initiate their auxval vector at the very
|
||||||
/// start of __libc_start_main (just keeping track of argv+argc+1), but we don't have such option (otherwise
|
/// start of __libc_start_main (just keeping track of argv+argc+1), but we don't have such option (otherwise
|
||||||
// this complexity of reading "/proc/self/auxv" or using __environ would not be necessary).
|
/// this complexity of reading "/proc/self/auxv" or using __environ would not be necessary).
|
||||||
|
|
||||||
/// To avoid this crashes on the re-exec call (see above how it would fail when creating `aux`, and if we used
|
/// To avoid this crashes on the re-exec call (see above how it would fail when creating `aux`, and if we used
|
||||||
/// __auxv_init_environ then it would SIGSEV on READing `__environ`) we capture this call for `AT_EXECFN` and
|
/// __auxv_init_environ then it would SIGSEV on READing `__environ`) we capture this call for `AT_EXECFN` and
|
||||||
@ -237,7 +237,7 @@ static unsigned long NO_SANITIZE_THREAD __auxv_init_environ(unsigned long type)
|
|||||||
// - __auxv_init_procfs -> __auxv_init_environ -> __getauxval_environ
|
// - __auxv_init_procfs -> __auxv_init_environ -> __getauxval_environ
|
||||||
static void * volatile getauxval_func = (void *)__auxv_init_procfs;
|
static void * volatile getauxval_func = (void *)__auxv_init_procfs;
|
||||||
|
|
||||||
unsigned long getauxval(unsigned long type)
|
unsigned long NO_SANITIZE_THREAD getauxval(unsigned long type)
|
||||||
{
|
{
|
||||||
return ((unsigned long (*)(unsigned long))getauxval_func)(type);
|
return ((unsigned long (*)(unsigned long))getauxval_func)(type);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user