Page MenuHomeFreeBSD

Some fixes for LD_BIND_NOW + ifuncs.
ClosedPublic

Authored by kib on Sat, Dec 1, 12:40 PM.

Details

Summary
  • Do not perform ifunc relocations together with other PLT relocations in PLT. Instead, do it during an additional pass over the init list, so that ifuncs are resolved in the order of dso dependencies. This allows the ifuncs resolvers to call info depended libs. init list now includes all objects instead of only objects with init/fini callables,
  • Disable relro protection around bind_now ifunc relocations.
  • Provide memset() and bzero() internal implementations. This will be needed when the functions in libc are converted to ifuncs. To be committed separately.

I considered calling ifunc resolvers of dso after initializers of all dependencies are processed, and decided that this is wrong/should not be supported. The order now is normal relocations for all objects->ifunc resolution in init order->initializers, where each step does complete pass over all loaded objects before moving to the next step.

Test Plan

LD_BIND_NOW=yes threaded_program

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib created this revision.Sat, Dec 1, 12:40 PM
kib edited the summary of this revision. (Show Details)Sat, Dec 1, 12:42 PM
kib edited the summary of this revision. (Show Details)Sat, Dec 1, 1:00 PM
kib added a subscriber: theraven.
emaste added a comment.Mon, Dec 3, 1:49 PM

Will test shortly

libexec/rtld-elf/rtld.c
5369 ↗(On Diff #51467)

EOL whitespace here

emaste added a comment.Mon, Dec 3, 4:36 PM

I tested this patch in my tree, with BIND_NOW on by default, PIE on by default, and rS341429 reverted. Sanity tests on a few threaded applications showed no issues. Building vanilla FreeBSD + this patch for testing now.

emaste added a comment.Mon, Dec 3, 6:49 PM

Smoke test in my staging tree (this patch plus 3 unrelated changes) looks good.

libexec/rtld-elf/rtld.c
5364 ↗(On Diff #51467)

I find disable_relro vs enforce_relro slightly odd, although for the 'turn on' case enforce does seem somehow more appropriate than enable.

emaste accepted this revision.Mon, Dec 3, 7:40 PM
This revision is now accepted and ready to land.Mon, Dec 3, 7:40 PM
This revision was automatically updated to reflect the committed changes.
kib reopened this revision.Mon, Dec 3, 8:00 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mon, Dec 3, 8:04 PM
Closed by commit rS341441: Some fixes for LD_BIND_NOW + ifuncs. (authored by kib, committed by ). · Explain Why
This revision was automatically updated to reflect the committed changes.