Bug 275270 - sanitizer re-exec with ASLR off fails
Summary: sanitizer re-exec with ASLR off fails
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks: 14.0-erratas
  Show dependency treegraph
 
Reported: 2023-11-22 22:28 UTC by Ed Maste
Modified: 2023-12-03 18:25 UTC (History)
3 users (show)

See Also:


Attachments
patch for 13 (929 bytes, patch)
2023-12-03 18:08 UTC, Ed Maste
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2023-11-22 22:28:06 UTC
Tracking PR for 14.0 EN for:

commit 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd
Author: Dimitry Andric <dim@FreeBSD.org>
Date:   Wed Nov 22 19:23:06 2023 +0100

    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
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2023-11-27 20:41:26 UTC
All MFCs apparently committed.
Comment 3 Ed Maste freebsd_committer freebsd_triage 2023-11-27 21:05:47 UTC
(In reply to Mark Linimon from comment #2)
This is a tracking PR for an EN to address this in 14.0
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2023-11-27 21:11:49 UTC
Right, the intent is to close this once the EN is released, hopefully quite soon.
Comment 5 Ed Maste freebsd_committer freebsd_triage 2023-11-29 01:11:25 UTC
I cannot reproduce a problem on FreeBSD 13.2, which has LLVM 14.0.5. This predates intercepting procctl, which was added in https://github.com/llvm/llvm-project/commit/c06ef17359efcab643c09ba54fa1381ea184986d
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2023-12-03 18:00:21 UTC
Fixed by FreeBSD-EN-23:15.sanitizer.
Comment 7 Ed Maste freebsd_committer freebsd_triage 2023-12-03 18:08:44 UTC
Created attachment 246752 [details]
patch for 13
Comment 8 Dimitry Andric freebsd_committer freebsd_triage 2023-12-03 18:25:18 UTC
(In reply to Ed Maste from comment #7)
Yes, that patch LGTM.