mbox series

[v6,0/2] Improve loader environment variable handling

Message ID 20231206132402.1356644-1-adhemerval.zanella@linaro.org
Headers show
Series Improve loader environment variable handling | expand

Message

Adhemerval Zanella Dec. 6, 2023, 1:24 p.m. UTC
Itremoves the tunable_strdup and make the GLIBC_TUNABLE parsing in place
(no more possible allocation failure).  The parsing now tracks the
tunable string start and its size.  The dl-tunable-parse.h adds helper
functions to help to parse, like an strcmp that also checks for size and
an iterator for suboptions that are comma-separated (used on hwcap
parsing by x86, powerpc, and s390x).

--

Changes from v5:
* Only parses the alias environment variable lenght if required.
* Fixed _dl_strtoul for hexa and octal inputs.

Changes from v4:
* Improve tunables value handling, now warnings for invalid and out of
  range numbers.

Changes from v3:
* Fixed tunable_initialize for strong aliases (it used the key length,
  instead of the value length).
* Added a assert on tunable_str_comma_init to ensure its value is non
  null.
* Added LD_WARN and LD_VERBOSE to filtered environment variables.

Changes from v2:
* Extend tst-tunables with tunables aliases tests.
* Use warning instead of an error to indicate invalid tunables.
* Fixed tunable_initialize for string aliases.

Changes from v1:
* Ignore most of the environment variables on security-sensitive mode.
* Extend tests.


Adhemerval Zanella (2):
  elf: Do not duplicate the GLIBC_TUNABLES string
  elf: Do not set invalid tunables values

 elf/dl-misc.c                                 |  10 +-
 elf/dl-tunables.c                             | 113 ++++++------
 elf/dl-tunables.h                             |   6 +-
 elf/tst-tunables.c                            |  96 +++++++++-
 sysdeps/generic/dl-tunables-parse.h           | 134 ++++++++++++++
 sysdeps/s390/cpu-features.c                   | 165 +++++++-----------
 .../unix/sysv/linux/aarch64/cpu-features.c    |  33 ++--
 .../unix/sysv/linux/powerpc/cpu-features.c    |  45 ++---
 .../sysv/linux/powerpc/tst-hwcap-tunables.c   |   6 +-
 sysdeps/x86/Makefile                          |   4 +-
 sysdeps/x86/cpu-tunables.c                    | 118 +++++--------
 sysdeps/x86/tst-hwcap-tunables.c              | 148 ++++++++++++++++
 12 files changed, 592 insertions(+), 286 deletions(-)
 create mode 100644 sysdeps/generic/dl-tunables-parse.h
 create mode 100644 sysdeps/x86/tst-hwcap-tunables.c