HomeFreeBSD

compiler-rt: avoid segfaults when re-exec'ing with ASLR

Description

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: 930a7c2ac67e, 96fe7c8ab0f6
MFC after: 3 days
Approved by: so
Security: FreeBSD-EN-23:15.sanitizer

(cherry picked from commit 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd)
(cherry picked from commit 1e4798e9677f17a7cdc9a1873a0c6e008fc620d8)

Details

Provenance
dimAuthored on Nov 22 2023, 6:23 PM
gordonCommitted on Nov 30 2023, 9:24 PM
Parents
rGf9716eee8ab4: release: update releng/14.0 to -RELEASE
Branches
Unknown
Tags
Unknown