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)
Sun, Mar 29, 10:36 AM
Unknown Object (File)
Sat, Mar 28, 8:15 PM
Unknown Object (File)
Fri, Mar 13, 2:33 AM
Unknown Object (File)
Mar 1 2026, 11:14 AM
Unknown Object (File)
Mar 1 2026, 6:27 AM
Unknown Object (File)
Feb 28 2026, 9:43 AM
Unknown Object (File)
Feb 20 2026, 6:52 AM
Unknown Object (File)
Feb 10 2026, 9:53 PM
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.