diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2021-01-12 16:28:27 +0000 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2021-01-21 14:05:15 +0000 |
commit | bfe04789a8d9014cf3177137651f8f93dd4a00ca (patch) | |
tree | 28465765d7ae957227b0be6cc4c9f8f579085bf6 /elf/dl-tunables.c | |
parent | 058308066c9ee3d08361a61cc36835abfe5ecfb6 (diff) | |
download | glibc-bfe04789a8d9014cf3177137651f8f93dd4a00ca.tar.gz glibc-bfe04789a8d9014cf3177137651f8f93dd4a00ca.tar.xz glibc-bfe04789a8d9014cf3177137651f8f93dd4a00ca.zip |
elf: Avoid RELATIVE relocs in __tunables_init
With static pie linking pointers in the tunables list need RELATIVE relocs since the absolute address is not known at link time. We want to avoid relocations so the static pie self relocation can be done after tunables are initialized. This is a simple fix that embeds the tunable strings into the tunable list instead of using pointers. It is possible to have a more compact representation of tunables with some additional complexity in the generator and tunable parser logic. Such optimization will be useful if the list of tunables grows. There is still an issue that tunables_strdup allocates and the failure handling code path is sufficiently complex that it can easily have RELATIVE relocations. It is possible to avoid the early allocation and only change environment variables in a setuid exe after relocations are processed. But that is a bigger change and early failure is fatal anyway so it is not as critical to fix right away. This is bug 27181. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-tunables.c')
-rw-r--r-- | elf/dl-tunables.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 33be00e447..e44476f204 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -351,7 +351,7 @@ __tunables_init (char **envp) /* Skip over tunables that have either been set already or should be skipped. */ - if (cur->initialized || cur->env_alias == NULL) + if (cur->initialized || cur->env_alias[0] == '\0') continue; const char *name = cur->env_alias; |