Page MenuHomeFreeBSD

rtld: properly handle update of several vars in rtld_set_var()
ClosedPublic

Authored by kib on Tue, Mar 24, 1:51 AM.
Tags
None
Referenced Files
F151071524: D56055.id174267.diff
Sun, Apr 5, 7:13 PM
F151071110: D56055.diff
Sun, Apr 5, 7:09 PM
F150984313: D56055.id174269.diff
Sun, Apr 5, 7:37 AM
Unknown Object (File)
Sat, Apr 4, 9:50 PM
Unknown Object (File)
Sat, Apr 4, 6:32 PM
Unknown Object (File)
Sat, Apr 4, 1:10 PM
Unknown Object (File)
Fri, Apr 3, 7:49 AM
Unknown Object (File)
Wed, Apr 1, 6:06 AM
Subscribers

Details

Summary
Besides setting the value in the array of the values, rtld sometimes
needs to recalculate some internal control variable for the change to
take effect.  Allow the variable description to supply a method called
on the update.  Lock the function with the bind lock for safe operation.

Mark several variables as allowed for update, since the on_update method
is provided for them.  The list is LD_BIND_NOW, LD_BIND_NOT,
LD_LIBMAP_DISABLE, LD_LOADFLTR.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Tue, Mar 24, 1:51 AM
libexec/rtld-elf/rtld.c
6737

Is this missing the on_update call?

kib marked an inline comment as done.

Do call on_update()

libexec/rtld-elf/rtld.c
6626

Does ld_debug need to be a global variable?

6651

Shouldn't we set it to false if the value is NULL?

6663

Should ld_bind_not be updated here if lvd->val is NULL? That's what happens during image activation time.

6688

Should dangerous_ld_env be recalculated if this variable (and some others) are toggled?

kib marked 4 inline comments as done.Wed, Mar 25, 3:48 AM
kib added inline comments.
libexec/rtld-elf/rtld.c
6626

I removed ld_debug altogether.

6651

I am not sure, but lets do it.

kib marked 2 inline comments as done.Wed, Mar 25, 3:51 AM
kib added inline comments.
libexec/rtld-elf/rtld.c
6688

I decided to never reset dangerous_ld_env back to false is it ever set to true.

Handle recalculations second-order effects.

libexec/rtld-elf/rtld.c
6626

|= looks wrong.

6696

Use rtld_recalc_bind_not()?

kib marked an inline comment as done.Wed, Mar 25, 4:15 AM
kib added inline comments.
libexec/rtld-elf/rtld.c
6626

Could you please explain why? I want to never flip it true->false.

More uses for rtld_recalc_bind_not().

markj added inline comments.
libexec/rtld-elf/rtld.c
6626

I wasn't sure why it should never flip true -> false, but after thinking some more it seems reasonable if one reads the description of the dangerous_ld_env variable. Maybe some short comment would be good to have.

This revision is now accepted and ready to land.Wed, Mar 25, 4:21 AM
kib marked an inline comment as done.

Note that dangerous_ld_env is never reset back to false.

This revision now requires review to proceed.Wed, Mar 25, 4:50 AM
libexec/rtld-elf/rtld.c
392–393

This means that some variables e.g. BIND_NOW can now be updated, right? I think those should be noted in the commit message too.

kib marked an inline comment as done.
kib edited the summary of this revision. (Show Details)

Update the commit message with the list of vars allowed in the commit.
Provide the whole list of changeable vars in rtld_get_var(3).

This revision was not accepted when it landed; it landed in state Needs Review.Thu, Mar 26, 11:42 PM
This revision was automatically updated to reflect the committed changes.