Page MenuHomeFreeBSD

rtld: do not relocate tlsinit address twice
ClosedPublic

Authored by kib on Jul 21 2025, 4:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 2, 9:09 PM
Unknown Object (File)
Tue, Aug 25, 1:18 AM
Unknown Object (File)
Fri, Aug 21, 9:23 AM
Unknown Object (File)
Sun, Aug 16, 8:39 PM
Unknown Object (File)
Sun, Aug 16, 2:03 PM
Unknown Object (File)
Aug 13 2026, 8:01 PM
Unknown Object (File)
Aug 13 2026, 8:01 PM
Unknown Object (File)
Aug 12 2026, 4:19 AM
Subscribers

Details

Summary
The addend for PT_TLS p_vaddr value should be obj' relocbase and not
mapbase.  It does not matter for dso which is linked at the address
zero, but for executables with non-zero link address mapbase is normally
already at the link base.  Then adding mapbase to phtls->p_vaddr adds
twice as much relocbase offset as needed.

PR:     288334
Reported by:    Jordan Gordeev <jgopensource@proton.me>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jul 21 2025, 4:18 AM

Please note in the commit message that this is specific to direct exec; I was initially confused how this was broken for so long without noticing as PDEs with TLS aren't that rare, especially prior to WITH_PIE being the default.

This revision is now accepted and ready to land.Jul 21 2025, 5:19 AM
This revision was automatically updated to reflect the committed changes.