]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
compiler-rt: avoid segfaults when re-exec'ing with ASLR
authorDimitry Andric <dim@FreeBSD.org>
Wed, 22 Nov 2023 18:23:06 +0000 (19:23 +0100)
committerDimitry Andric <dim@FreeBSD.org>
Sat, 25 Nov 2023 09:05:14 +0000 (10:05 +0100)
commit7c25a53a2cb975e516cfea78898bfb850db88524
treeb6eece2e0b9017bad053e8ba5789c99a577678d8
parentb54addc27ceb76abf9b4aeec3bca924e9599169f
compiler-rt: avoid segfaults when re-exec'ing with ASLR

After 930a7c2ac67e ("compiler-rt: re-exec with ASLR disabled when
necessary") and 96fe7c8ab0f6 ("compiler-rt: support ReExec() on
FreeBSD"), binaries linked against the sanitizer libraries may segfault
due to procctl(2) being intercepted. Instead, the non-intercepted
internal_procctl() should be called.

Similarly, the ReExec() function that re-executes the binary after
turning off ASLR should not call elf_aux_info(3) and realpath(3), since
these will also be intercepted. Instead, loop directly over the elf aux
info vector to find the executable path, and avoid calling realpath(3)
since it is actually unwanted for this use case.

Fixes: 930a7c2ac67e96fe7c8ab0f6
MFC after: 3 days

(cherry picked from commit 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd)
contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp