glibc:nsz/bug23293-v5

Last commit made on 2022-05-04
Get this branch:
git clone -b nsz/bug23293-v5 https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
nsz/bug23293-v5
Repository:
lp:glibc

Recent commits

fc7beeb... by Szabolcs Nagy <email address hidden>

aarch64: Move ld.so _start to separate file and drop _dl_skip_args

A separate asm file is easier to maintain than a macro that expands to
inline asm.

The RTLD_START macro is only needed now because _dl_start is local in
rtld.c, but _start has to call it, if _dl_start was made hidden then it
could be empty.

_dl_skip_args is no longer needed.

---
v4:
- adjust commit message about _dl_skip_args.
v3:
- mention _dl_skip_args
v2:
- fix typo in commit message.

3f32aa2... by Szabolcs Nagy <email address hidden>

linux: Add a getauxval test [BZ #23293]

This is for bug 23293 and it relies on the glibc test system running
tests via explicit ld.so invokation by default.

Reviewed-by: Florian Weimer <email address hidden>

---
v4:
- New patch.

8db827d... by Szabolcs Nagy <email address hidden>

rtld: Remove DL_ARGV_NOT_RELRO

This is no longer needed because _dl_skip_args is always 0, so the
target specific code that modifies argv after relro protection is
applied is no longer used.

After the patch relro protection is applied to _dl_argv consistently
on all targets.

Reviewed-by: Florian Weimer <email address hidden>
Tested-by: Florian Weimer <email address hidden>

---
v4:
- New patch.

73fd4d7... by Szabolcs Nagy <email address hidden>

rtld: Use generic argv adjustment in ld.so [BZ #23293]

When an executable is invoked as

  ./ld.so [ld.so-args] ./exe [exe-args]

then the argv is adujusted in ld.so before calling the entry point of
the executable so ld.so args are not visible to it. On most targets
this requires moving argv, env and auxv on the stack to ensure correct
stack alignment at the entry point. This had several issues:

- The code for this adjustment on the stack is written in asm as part
  of the target specific ld.so _start code which is hard to maintain.

- The adjustment is done after _dl_start returns, where it's too late
  to update GLRO(dl_auxv), as it is already readonly, so it points to
  memory that was clobbered by the adjustment. This is bug 23293.

- _environ is also wrong in ld.so after the adjustment, but it is
  likely not used after _dl_start returns so this is not user visible.

- _dl_argv was updated, but for this it was moved out of relro, which
  changes security properties across targets unnecessarily.

This patch introduces a generic _dl_start_args_adjust function that
handles the argument adjustments after ld.so processed its own args
and before relro protection is applied. The initial sp at ld.so entry
is passed down to dl_main so it can do the adjustment.

The same algorithm is used on all targets, _dl_skip_args is now 0, so
existing target specific adjustment code is no longer used. The bug
affects aarch64, alpha, arc, arm, csky, ia64, nios2, s390-32 and sparc,
other targets don't need the change in principle, but it does not hurt
and makes the behaviour more consistent.

The GNU Hurd start code needed some changes, because it relied on
_dl_skip_args after dl_main returned.

Follow up patches can remove _dl_skip_args and DL_ARGV_NOT_RELRO.

---
v5:
- Hurd specific changes.
v4:
- New code is unconditionally used on all targets.
- Hide auxv adjustments behind HAVE_AUX_VECTOR.
- DL_NEED_START_ARGS_ADJUST macro is removed.
- _dl_skip_args is no longer unused.
- start_argptr is passed down to dl_main instead of using a global.
- moved aarch64 DL_ARGV_NOT_RELRO removal to separate patch.
v2:
- use p != NULL, and a_type != AT_NULL
- remove the confusing paragraph from the commit message.

8e28aa3... by Fangrui Song <email address hidden>

elf: Remove fallback to the start of DT_STRTAB for dladdr

When neither DT_HASH nor DT_GNU_HASH is present, the code scans
[DT_SYMTAB, DT_STRTAB). However, there is no guarantee that .dynstr
immediately follows .dynsym (e.g. lld typically places .gnu.version
after .dynsym).

In the absence of a hash table, symbol lookup will always fail
(map->l_nbuckets == 0 in dl-lookup.c) as if the object has no symbol, so
it seems fair for dladdr to do the same.

Reviewed-by: Florian Weimer <email address hidden>

4e7e4f3... by Fangrui Song <email address hidden>

powerpc32: Remove unused HAVE_PPC_SECURE_PLT

82a79e7d1843f9d90075a0bf2f04557040829bb0 removed the only user of
HAVE_PPC_SECURE_PLT.

Reviewed-by: Florian Weimer <email address hidden>

d056c21... by Florian Weimer

dlfcn: Implement the RTLD_DI_PHDR request type for dlinfo

The information is theoretically available via dl_iterate_phdr as
well, but that approach is very slow if there are many shared
objects.

Reviewed-by: Carlos O'Donell <email address hidden>
Tested-by: Carlos O'Donell <email address hidden>

93804a1... by Florian Weimer

manual: Document the dlinfo function

Reviewed-by: Carlos O'Donell <email address hidden>
Tested-by: Carlos O'Donell <email address hidden>

e47de5c... by Florian Weimer

Do not use --hash-style=both for building glibc shared objects

The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.

Reviewed-by: Carlos O'Donell <email address hidden>

5b5b101... by Siddhesh Poyarekar <email address hidden>

benchtests: Better libmvec integration

Improve libmvec benchmark integration so that in future other
architectures may be able to run their libmvec benchmarks as well. This
now allows libmvec benchmarks to be run with `make BENCHSET=bench-math`.

Signed-off-by: Siddhesh Poyarekar <email address hidden>