Page MenuHomeFreeBSD

rtld: do not relocate tlsinit address twice
ClosedPublic

Authored by kib on Jul 21 2025, 4:18 AM.
Tags
None
Referenced Files
F144363766: D51448.id158848.diff
Sun, Feb 8, 1:37 AM
Unknown Object (File)
Sat, Feb 7, 5:38 PM
Unknown Object (File)
Sat, Feb 7, 5:01 AM
Unknown Object (File)
Sun, Feb 1, 11:16 PM
Unknown Object (File)
Sat, Jan 31, 9:35 AM
Unknown Object (File)
Dec 31 2025, 9:25 AM
Unknown Object (File)
Dec 29 2025, 3:42 AM
Unknown Object (File)
Dec 29 2025, 1:02 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.