[0/8,0/8] elf: Fix auditing with multiple auditors and la_pltexit

Message ID 20260928185535.1353957-1-adhemerval.zanella@linaro.org (mailing list archive)
Headers
Series elf: Fix auditing with multiple auditors and la_pltexit |

Message

Adhemerval Zanella Netto Sept. 28, 2026, 6:55 p.m. UTC
  While reviewing the rtld-audit documentation patch, I found three issues
in ld.so when more than one auditor is loaded:

  - dlsym bindings are passed to the wrong auditor's la_symbind
    (BZ 34684).
  - la_symbind and la_pltenter flags set by one auditor leak into the
    next ones (BZ 34687).
  - LA_SYMB_NOPLTENTER and LA_SYMB_NOPLTEXIT are not honored per
    auditor (BZ 34688).

The first three patches fix these.  The test for the last one,
tst-audit-plt-flags, also exercises the la_pltexit path of
_dl_runtime_profile.  That path turned out to be broken on aarch64
(with BTI), alpha, LoongArch, and RISC-V. On hppa the path was never
taken.  The remaining five patches fix each ABI and remove its XFAIL.
The LoongArch and RISC-V fixes are essentially the same, since both
trampolines share the same code and the same bugs.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, alpha-linux-gnu, hppa-linux-gnu,
loongarch64-linux-gnu, mips64el-linux-gnu, powerpc64-linux-gnu,
powerpc64le-linux-gnu, riscv64-linux-gnu, s390x-linux-gnu, and
sparc64-linux-gnu.

Adhemerval Zanella (8):
  elf: Fix auditor iteration in _dl_audit_symbind_alt (BZ 34684)
  elf: Keep la_symbind and la_pltenter flags per auditor (BZ 34687)
  elf: Honor LA_SYMB_NOPLTENTER/NOPLTEXIT per auditor (BZ 34688)
  aarch64: Return with ret from the la_pltexit path of
    _dl_runtime_profile
  alpha: Fix the la_pltexit path of _dl_runtime_profile
  LoongArch: Fix the la_pltexit path of _dl_runtime_profile
  riscv: Fix the la_pltexit path of _dl_runtime_profile
  hppa: Fix the la_pltexit path of _dl_runtime_profile

 elf/Makefile                       |  31 +++++++
 elf/dl-audit.c                     |  40 +++++----
 elf/tst-audit-plt-flags-mod.c      |  35 ++++++++
 elf/tst-audit-plt-flags.c          | 124 ++++++++++++++++++++++++++
 elf/tst-audit-symbind-dlsym-mod.c  |  19 ++++
 elf/tst-audit-symbind-dlsym.c      |  35 ++++++++
 elf/tst-audit-symbind-flags-mod.c  |  29 ++++++
 elf/tst-audit-symbind-flags.c      | 137 +++++++++++++++++++++++++++++
 elf/tst-auditmod-plt-flags-a.c     |  85 ++++++++++++++++++
 elf/tst-auditmod-plt-flags-b.c     |  22 +++++
 elf/tst-auditmod-symbind-dlsym-a.c |  50 +++++++++++
 elf/tst-auditmod-symbind-dlsym-b.c |  50 +++++++++++
 elf/tst-auditmod-symbind-flags-a.c |  64 ++++++++++++++
 elf/tst-auditmod-symbind-flags-b.c |  64 ++++++++++++++
 sysdeps/aarch64/dl-trampoline.S    |   4 +-
 sysdeps/alpha/dl-trampoline.S      |  26 ++++--
 sysdeps/hppa/dl-trampoline.S       |  53 ++++++-----
 sysdeps/loongarch/dl-trampoline.h  |  35 ++++----
 sysdeps/mips/Makefile              |   1 +
 sysdeps/riscv/dl-trampoline.S      |  17 ++--
 20 files changed, 853 insertions(+), 68 deletions(-)
 create mode 100644 elf/tst-audit-plt-flags-mod.c
 create mode 100644 elf/tst-audit-plt-flags.c
 create mode 100644 elf/tst-audit-symbind-dlsym-mod.c
 create mode 100644 elf/tst-audit-symbind-dlsym.c
 create mode 100644 elf/tst-audit-symbind-flags-mod.c
 create mode 100644 elf/tst-audit-symbind-flags.c
 create mode 100644 elf/tst-auditmod-plt-flags-a.c
 create mode 100644 elf/tst-auditmod-plt-flags-b.c
 create mode 100644 elf/tst-auditmod-symbind-dlsym-a.c
 create mode 100644 elf/tst-auditmod-symbind-dlsym-b.c
 create mode 100644 elf/tst-auditmod-symbind-flags-a.c
 create mode 100644 elf/tst-auditmod-symbind-flags-b.c