mbox

[v5,0/7] fix ifunc with static pie [BZ #27072]

Message ID cover.1611155254.git.szabolcs.nagy@arm.com
Headers

Message

Szabolcs Nagy Jan. 20, 2021, 3:29 p.m. UTC
  v5:
- reordered patches.
- config check SUPPORT_STATIC_PIE (instead of PI_STATIC_AND_HIDDEN)
- fix __ehdr_start differently: just drop weak.
- update commit messages for hidden visibility changes.

v4:
- added patches from H.J.Lu:
	- x86: fix libmvec tests
	- x86: fix syscalls in libc_enable_secure
	- x86: avoid relative reloc for _dl_sysinfo
	- x86: add ifunc test
- i386 cannot mark all symbols hidden, so use fine grain
  marking in files that participate in early code before
  static pie self relocation.
- the patch that makes all libc symbols hidden is still
  included: it is now only an optimization for non-i386
  targets.

v3:
- refactor tunables: move internals out of dl-tunables.h
- use generated max string length in the tunables list
  instead of magic values.

v2:
- check PI_STATIC_AND_HIDDEN for --enable-static-pie
- change string buffer sizes in the tunables
- fix env_alias == NULL logic in __tunables_init
- move __ehdr_start processing after self relocation


force pushed into nsz/bug27072 branch.

Tested on aarch64, i686 and x86_64 with and without the last
patch (some of the make check is still running though).

Issues that are not addressed:
- tunables try to allocate memory even with non-suid exe.
  allocation is only needed for rewriting the GLIBC_TUNABLES
  env var. (i think a case can be made that if anything there
  is TUNABLE_SECLEVEL_SXID_ERASE then this env var would be
  simply dropped, that would simplify this significantly).
- __sbrk only needs the hidden visibility magic because of
  tunables, ideally we would not do allocations before self
  relocation.
- tunable list data structure is not optimized for compactness.

Szabolcs Nagy (7):
  elf: Make the tunable struct definition internal only
  elf: Avoid RELATIVE relocs in __tunables_init
  configure: Check for static PIE support
  csu: Avoid weak ref for __ehdr_start in static PIE
  Use hidden visibility for early static PIE code
  csu: Move static pie self relocation later [BZ #27072]
  Make libc symbols hidden in static PIE

 config.h.in                                  |  3 ++
 configure                                    | 13 ++++++
 configure.ac                                 |  4 ++
 csu/libc-start.c                             | 15 ++++++-
 elf/dl-reloc-static-pie.c                    |  2 +
 elf/dl-support.c                             |  6 +++
 elf/dl-tunable-types.h                       | 42 +++++++++++++++-----
 elf/dl-tunables.c                            |  6 ++-
 elf/dl-tunables.h                            | 35 ++++------------
 elf/enbl-secure.c                            |  4 ++
 include/libc-symbols.h                       |  9 ++++-
 misc/sbrk.c                                  |  4 ++
 scripts/gen-tunables.awk                     | 16 +++++++-
 sysdeps/aarch64/configure                    |  4 ++
 sysdeps/aarch64/configure.ac                 |  3 ++
 sysdeps/i386/configure                       |  3 ++
 sysdeps/i386/configure.ac                    |  3 ++
 sysdeps/unix/sysv/linux/aarch64/libc-start.c |  5 +++
 sysdeps/x86/libc-start.c                     |  5 +++
 sysdeps/x86_64/configure                     |  3 ++
 sysdeps/x86_64/configure.ac                  |  3 ++
 21 files changed, 144 insertions(+), 44 deletions(-)