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)
Tue, Apr 21, 3:21 AM
Unknown Object (File)
Mon, Apr 20, 10:41 PM
Unknown Object (File)
Mon, Apr 20, 7:21 PM
Unknown Object (File)
Sun, Apr 19, 10:14 AM
Unknown Object (File)
Sun, Apr 19, 6:04 AM
Unknown Object (File)
Tue, Apr 14, 7:27 PM
Unknown Object (File)
Tue, Apr 14, 6:22 PM
Unknown Object (File)
Tue, Apr 14, 9:42 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.