Page MenuHomeFreeBSD

rtld: do not relocate tlsinit address twice
ClosedPublic

Authored by kib on Jul 21 2025, 4:18 AM.
Tags
None
Referenced Files
F131832386: D51448.id.diff
Sat, Oct 11, 1:22 PM
F131832383: D51448.id158848.diff
Sat, Oct 11, 1:22 PM
F131832380: D51448.id158847.diff
Sat, Oct 11, 1:22 PM
F131792354: D51448.diff
Sat, Oct 11, 5:06 AM
Unknown Object (File)
Sat, Oct 4, 11:18 PM
Unknown Object (File)
Sat, Oct 4, 9:44 PM
Unknown Object (File)
Thu, Oct 2, 3:49 AM
Unknown Object (File)
Thu, Oct 2, 1:05 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.