public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v7 00/16] Multiple rtld-audit fixes
@ 2021-12-22 13:26 Adhemerval Zanella
  2021-12-22 13:26 ` [PATCH v7 01/16] elf: Add _dl_audit_objopen Adhemerval Zanella
                   ` (16 more replies)
  0 siblings, 17 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-12-22 13:26 UTC (permalink / raw)
  To: libc-alpha, fweimer; +Cc: John Mellor-Crummey, Ben Woodard

This patchset fixes most of the rtld-audit issues brought by John
Mellor-Crummey [1] while trying to use it along with the HPCToolkit.
This should cover all the issues listed as 'Tier 1' [2] (the aarch64
SVE requires additional work, so it is postpone to 2.36) and also
most of the 'Tier2' issue (BZ#28096 inclusive) which prevents the use
of some glibc function that uses TLS internally on the audit module.

There is also some point brough by John Melloc-Crummey documents that
I don't have a straighforward answer so I haven't added on this
patchset:

  1 la_activity(LA_ACT_ADD) is never called for auditor namespaces,
     even though la_objopen and la_activity(LA_ACT_CONSISTENT) are.

  There is no easy solution for this: we need at least to load the
  *first* auditor to actually issue the la_activity(LA_ACT_ADD).  It
  means that it would *only* work for subsequent audit modules, and
  adding this specific semantic is confusing and does not really
  improve things (it only helps when multiple audit modules are used).

  2. la_objopen is called for the main binary and for ld.so before the
     first la_activity(LA_ACT_ADD) call.  This contradicts the pattern
     found in a successful dlopen (where la_activity(LA_ACT_ADD)
     precedes la_objopen).

  The constrain here is we need to handle DT_AUDIT and DT_DEPAUDIT
  dynamic tags, which means we need to first load the executable in
  memory to parse the required audit modules.  So we need to first parse
  the dynamic audit tags, load the audit modules, and then load the
  object itself.

  3. For non-PIE executables the base address listed in link_map->l_addr
     for the main application binary is 0, even though dladdr is able to
     recover the correct offset. La_objopen is affected by this.

  This would require to change an internal semantic for link_map->l_addr.
  This is not straighfoward and I am not sure about the direct gains.

I have checked the patches on x86_64, i686, aarch64, armv7, powerpc64,
powerpc64le, and powerpc.

[1] https://sourceware.org/pipermail/libc-alpha/2021-June/127636.html
[2] https://docs.google.com/document/d/1dVaDBdzySecxQqD6hLLzDrEF18M1UtjDna9gL5BWWI0/edit#
[3] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/ld-audit-fixes

Changes from v6:
  - Dropped SVE, main application on main_map l_name, and Run
    constructors if executable has a soname of a dependency patches.
  - Bumped LAV_VERSION to 2 on la_symbind bind-now support.
  - Added extension pointer on aarch64 fix.
  - Moved the refactor patch at the start of the set.
  - Changed _dl_audit_objsearch interface.

Changes from v5:
  - Fixed build with --enable-profiling=yes.
  - Moved la_activity (LA_ACT_ADD) *after* _dl_add_to_namespace_list()
    for BZ#28062 fix.
  - Fixed powerpc64 ELFv1 OPD toc setup for bind-now.
  - Fixed testsuite issues for ia64.
  - Removed LA_SYMB_BINDNOW now that LA_SYMB_NOPLTENTER and
    LA_SYMB_NOPLTEXIT is passed for bind-now.

Changes from v4:
  - Added a fix for constructors if executable has a soname of a
    dependency
  - Rebased against master.

Changes from v3
  - Added a aarch64 SVE RFC patch.
  - Fixed an issue with bind-now fix on powerpc64 ELFv1.
  - Rebased against master.

Changes from v2
  - Refactored rtld-audit code to move common come to dl-audit.c.
  - Issue audit la_objopen() for vDSO.
  - Isseu la_activity during application exit.
  - Issue la_symbind() for bind-now (BZ #23734).
  - Fix runtime linker auditing on aarch64 (BZ #26643)

Changes from v1
  - Fixed -fstack-protector-all tst-auditmod17.
  - Simplify the _dl_call_libc_early_init call the 'Fix audit
    regression' patch.
  - Remove symbind check fr BZ#15333.
  - Added the BZ#28096 fix.

Adhemerval Zanella (15):
  elf: Add _dl_audit_objopen
  elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid
  elf: Add _dl_audit_objsearch
  elf: Add _dl_audit_objclose
  elf: Add _dl_audit_symbind_alt and _dl_audit_symbind
  elf: Add _dl_audit_preinit
  elf: Add _dl_audit_pltenter
  elf: Add _dl_audit_pltexit
  elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)
  elf: Add audit tests for modules with TLSDESC
  elf: Do not fail for failed dlmopen on audit modules (BZ #28061)
  elf: Fix initial-exec TLS access on audit modules (BZ #28096)
  elf: Issue audit la_objopen for vDSO
  elf: Add la_activity during application exit
  elf: Issue la_symbind for bind-now (BZ #23734)

Ben Woodard (1):
  elf: Fix runtime linker auditing on aarch64 (BZ #26643)

 NEWS                                      |   7 +
 bits/link_lavcurrent.h                    |   2 +-
 csu/libc-start.c                          |  23 +-
 elf/Makefile                              | 147 ++++++++-
 elf/Versions                              |   1 +
 elf/dl-audit.c                            | 385 ++++++++++++++++++++++
 elf/dl-close.c                            |  67 +---
 elf/dl-fini.c                             |  25 +-
 elf/dl-load.c                             | 107 ++----
 elf/dl-object.c                           |  20 +-
 elf/dl-open.c                             |  22 +-
 elf/dl-reloc.c                            |  20 +-
 elf/dl-runtime.c                          | 252 ++------------
 elf/dl-support.c                          |   8 +
 elf/dl-sym-post.h                         |  47 +--
 elf/dl-tls.c                              |  16 +-
 elf/do-rel.h                              |  57 +++-
 elf/rtld.c                                |  73 +---
 elf/setup-vdso.h                          |   2 +-
 elf/sotruss-lib.c                         |   6 +
 elf/tst-audit-tlsdesc-dlopen.c            |  67 ++++
 elf/tst-audit-tlsdesc-mod1.c              |  41 +++
 elf/tst-audit-tlsdesc-mod2.c              |  33 ++
 elf/tst-audit-tlsdesc.c                   |  60 ++++
 elf/tst-audit19a.c                        |  38 +++
 elf/tst-audit19b.c                        |  94 ++++++
 elf/tst-audit19bmod.c                     |  23 ++
 elf/tst-audit20.c                         |  25 ++
 elf/tst-audit21.c                         |  42 +++
 elf/tst-audit22.c                         | 124 +++++++
 elf/tst-audit23.c                         | 173 ++++++++++
 elf/tst-audit23mod.c                      |  23 ++
 elf/tst-audit24a.c                        |  36 ++
 elf/tst-audit24amod1.c                    |  31 ++
 elf/tst-audit24amod2.c                    |  25 ++
 elf/tst-audit24b.c                        |  37 +++
 elf/tst-audit24bmod1.c                    |  31 ++
 elf/tst-audit24bmod2.c                    |  23 ++
 elf/tst-audit24c.c                        |   2 +
 elf/tst-audit24d.c                        |  36 ++
 elf/tst-audit24dmod1.c                    |  33 ++
 elf/tst-audit24dmod2.c                    |  28 ++
 elf/tst-audit24dmod3.c                    |  31 ++
 elf/tst-audit24dmod4.c                    |  25 ++
 elf/tst-audit25a.c                        | 127 +++++++
 elf/tst-audit25b.c                        | 128 +++++++
 elf/tst-audit25mod1.c                     |  30 ++
 elf/tst-audit25mod2.c                     |  30 ++
 elf/tst-audit25mod3.c                     |  22 ++
 elf/tst-audit25mod4.c                     |  22 ++
 elf/tst-auditmod-tlsdesc.c                |  25 ++
 elf/tst-auditmod19a.c                     |  25 ++
 elf/tst-auditmod19b.c                     |  46 +++
 elf/tst-auditmod20.c                      |  57 ++++
 elf/tst-auditmod21a.c                     |  80 +++++
 elf/tst-auditmod21b.c                     |  22 ++
 elf/tst-auditmod22.c                      |  51 +++
 elf/tst-auditmod23.c                      |  69 ++++
 elf/tst-auditmod24.h                      |  29 ++
 elf/tst-auditmod24a.c                     | 114 +++++++
 elf/tst-auditmod24b.c                     | 104 ++++++
 elf/tst-auditmod24c.c                     |   3 +
 elf/tst-auditmod24d.c                     | 120 +++++++
 elf/tst-auditmod25.c                      |  79 +++++
 include/dlfcn.h                           |   2 +
 include/link.h                            |   4 +
 sysdeps/aarch64/Makefile                  |  20 ++
 sysdeps/aarch64/bits/link.h               |  26 +-
 sysdeps/aarch64/dl-audit-check.h          |  28 ++
 sysdeps/aarch64/dl-link.sym               |   6 +-
 sysdeps/aarch64/dl-trampoline.S           |  99 ++++--
 sysdeps/aarch64/tst-audit26.c             |  37 +++
 sysdeps/aarch64/tst-audit26mod.c          |  33 ++
 sysdeps/aarch64/tst-audit26mod.h          |  50 +++
 sysdeps/aarch64/tst-audit27.c             |  64 ++++
 sysdeps/aarch64/tst-audit27mod.c          |  95 ++++++
 sysdeps/aarch64/tst-audit27mod.h          |  67 ++++
 sysdeps/aarch64/tst-auditmod26.c          | 103 ++++++
 sysdeps/aarch64/tst-auditmod27.c          | 180 ++++++++++
 sysdeps/alpha/dl-trampoline.S             |   8 +-
 sysdeps/arm/dl-machine-rel.h              |   2 +
 sysdeps/arm/dl-trampoline.S               |   2 +-
 sysdeps/generic/dl-audit-check.h          |  23 ++
 sysdeps/generic/dl-fixup-attribute.h      |  24 ++
 sysdeps/generic/dl-lookupcfg.h            |   3 +
 sysdeps/generic/dl-machine-rel.h          |   2 +
 sysdeps/generic/ldsodefs.h                |  52 +++
 sysdeps/hppa/dl-lookupcfg.h               |   3 +
 sysdeps/hppa/dl-runtime.c                 |   2 +-
 sysdeps/hppa/dl-trampoline.S              |   6 +-
 sysdeps/i386/dl-fixup-attribute.h         |  30 ++
 sysdeps/i386/dl-machine-rel.h             |   2 +
 sysdeps/i386/dl-machine.h                 |  23 --
 sysdeps/i386/dl-trampoline.S              |   2 +-
 sysdeps/ia64/dl-lookupcfg.h               |   3 +
 sysdeps/ia64/dl-trampoline.S              |  16 +-
 sysdeps/m68k/dl-trampoline.S              |   2 +-
 sysdeps/mips/dl-machine-rel.h             |   1 +
 sysdeps/powerpc/dl-lookupcfg.h            |  39 +++
 sysdeps/powerpc/powerpc64/dl-trampoline.S |   4 +-
 sysdeps/s390/s390-32/dl-trampoline.h      |   4 +-
 sysdeps/s390/s390-64/dl-trampoline.h      |   2 +-
 sysdeps/sh/dl-trampoline.S                |   4 +-
 sysdeps/sparc/sparc32/dl-trampoline.S     |   2 +-
 sysdeps/sparc/sparc64/dl-trampoline.S     |   2 +-
 sysdeps/x86_64/dl-runtime.h               |   2 +-
 sysdeps/x86_64/dl-trampoline.h            |   6 +-
 107 files changed, 3978 insertions(+), 658 deletions(-)
 create mode 100644 elf/dl-audit.c
 create mode 100644 elf/tst-audit-tlsdesc-dlopen.c
 create mode 100644 elf/tst-audit-tlsdesc-mod1.c
 create mode 100644 elf/tst-audit-tlsdesc-mod2.c
 create mode 100644 elf/tst-audit-tlsdesc.c
 create mode 100644 elf/tst-audit19a.c
 create mode 100644 elf/tst-audit19b.c
 create mode 100644 elf/tst-audit19bmod.c
 create mode 100644 elf/tst-audit20.c
 create mode 100644 elf/tst-audit21.c
 create mode 100644 elf/tst-audit22.c
 create mode 100644 elf/tst-audit23.c
 create mode 100644 elf/tst-audit23mod.c
 create mode 100644 elf/tst-audit24a.c
 create mode 100644 elf/tst-audit24amod1.c
 create mode 100644 elf/tst-audit24amod2.c
 create mode 100644 elf/tst-audit24b.c
 create mode 100644 elf/tst-audit24bmod1.c
 create mode 100644 elf/tst-audit24bmod2.c
 create mode 100644 elf/tst-audit24c.c
 create mode 100644 elf/tst-audit24d.c
 create mode 100644 elf/tst-audit24dmod1.c
 create mode 100644 elf/tst-audit24dmod2.c
 create mode 100644 elf/tst-audit24dmod3.c
 create mode 100644 elf/tst-audit24dmod4.c
 create mode 100644 elf/tst-audit25a.c
 create mode 100644 elf/tst-audit25b.c
 create mode 100644 elf/tst-audit25mod1.c
 create mode 100644 elf/tst-audit25mod2.c
 create mode 100644 elf/tst-audit25mod3.c
 create mode 100644 elf/tst-audit25mod4.c
 create mode 100644 elf/tst-auditmod-tlsdesc.c
 create mode 100644 elf/tst-auditmod19a.c
 create mode 100644 elf/tst-auditmod19b.c
 create mode 100644 elf/tst-auditmod20.c
 create mode 100644 elf/tst-auditmod21a.c
 create mode 100644 elf/tst-auditmod21b.c
 create mode 100644 elf/tst-auditmod22.c
 create mode 100644 elf/tst-auditmod23.c
 create mode 100644 elf/tst-auditmod24.h
 create mode 100644 elf/tst-auditmod24a.c
 create mode 100644 elf/tst-auditmod24b.c
 create mode 100644 elf/tst-auditmod24c.c
 create mode 100644 elf/tst-auditmod24d.c
 create mode 100644 elf/tst-auditmod25.c
 create mode 100644 sysdeps/aarch64/dl-audit-check.h
 create mode 100644 sysdeps/aarch64/tst-audit26.c
 create mode 100644 sysdeps/aarch64/tst-audit26mod.c
 create mode 100644 sysdeps/aarch64/tst-audit26mod.h
 create mode 100644 sysdeps/aarch64/tst-audit27.c
 create mode 100644 sysdeps/aarch64/tst-audit27mod.c
 create mode 100644 sysdeps/aarch64/tst-audit27mod.h
 create mode 100644 sysdeps/aarch64/tst-auditmod26.c
 create mode 100644 sysdeps/aarch64/tst-auditmod27.c
 create mode 100644 sysdeps/generic/dl-audit-check.h
 create mode 100644 sysdeps/generic/dl-fixup-attribute.h
 create mode 100644 sysdeps/i386/dl-fixup-attribute.h
 create mode 100644 sysdeps/powerpc/dl-lookupcfg.h

-- 
2.32.0


^ permalink raw reply	[flat|nested] 41+ messages in thread
* Re: [PATCH v7 14/16] elf: Add la_activity during application exit
@ 2021-12-27  5:13 jma14
  2021-12-27 13:20 ` Adhemerval Zanella
  0 siblings, 1 reply; 41+ messages in thread
From: jma14 @ 2021-12-27  5:13 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella; +Cc: John Mellor-Crummey, libc-alpha


On December 24, 2021 11:50:54 AM CST, Florian Weimer via Libc-alpha  
<libc-alpha@sourceware.org> wrote:
> * Adhemerval Zanella:
>
>> la_activity is not called during application exit, even though
>> la_objclose is.
>>
>> Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
>
> Still looks good, thanks.

I still have a concern with this patch, the included test does not  
actually test the fix, it passes even without the changes in dl-fini.c.

I believe these two checks suffice to test the new functionality:
   - la_objclose should be called after la_activity(LA_ACT_DELETE) for  
the closed object's namespace. (Since dlclose is not used in this  
test, AFAICT la_objclose is only called during program termination.)
   - la_activity(LA_ACT_CONSISTENT) should be the last callback  
received for every namespace.

-Jonathon



^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2021-12-27 20:31 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 13:26 [PATCH v7 00/16] Multiple rtld-audit fixes Adhemerval Zanella
2021-12-22 13:26 ` [PATCH v7 01/16] elf: Add _dl_audit_objopen Adhemerval Zanella
2021-12-24 11:50   ` Florian Weimer
2021-12-22 13:26 ` [PATCH v7 02/16] elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid Adhemerval Zanella
2021-12-24 11:58   ` Florian Weimer
2021-12-27 12:10     ` Adhemerval Zanella
2021-12-22 13:26 ` [PATCH v7 03/16] elf: Add _dl_audit_objsearch Adhemerval Zanella
2021-12-24 12:05   ` Florian Weimer
2021-12-27 12:20     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 04/16] elf: Add _dl_audit_objclose Adhemerval Zanella
2021-12-24 12:10   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 05/16] elf: Add _dl_audit_symbind_alt and _dl_audit_symbind Adhemerval Zanella
2021-12-24 12:42   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 06/16] elf: Add _dl_audit_preinit Adhemerval Zanella
2021-12-24 12:47   ` Florian Weimer
2021-12-24 12:53   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 07/16] elf: Add _dl_audit_pltenter Adhemerval Zanella
2021-12-24 13:57   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 08/16] elf: Add _dl_audit_pltexit Adhemerval Zanella
2021-12-24 14:17   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 09/16] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533) Adhemerval Zanella
2021-12-24 16:05   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 10/16] elf: Add audit tests for modules with TLSDESC Adhemerval Zanella
2021-12-24 16:55   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 11/16] elf: Do not fail for failed dlmopen on audit modules (BZ #28061) Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 12/16] elf: Fix initial-exec TLS access on audit modules (BZ #28096) Adhemerval Zanella
2021-12-24 17:17   ` Florian Weimer
2021-12-27 20:13     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 13/16] elf: Issue audit la_objopen for vDSO Adhemerval Zanella
2021-12-24 17:44   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 14/16] elf: Add la_activity during application exit Adhemerval Zanella
2021-12-24 17:50   ` Florian Weimer
2021-12-22 13:27 ` [PATCH v7 15/16] elf: Issue la_symbind for bind-now (BZ #23734) Adhemerval Zanella
2021-12-24 18:50   ` Florian Weimer
2021-12-27 20:17     ` Adhemerval Zanella
2021-12-22 13:27 ` [PATCH v7 16/16] elf: Fix runtime linker auditing on aarch64 (BZ #26643) Adhemerval Zanella
2021-12-24 18:53   ` Florian Weimer
2021-12-27 20:31     ` Adhemerval Zanella
2021-12-24 11:49 ` [PATCH v7 00/16] Multiple rtld-audit fixes Florian Weimer
2021-12-27  5:13 [PATCH v7 14/16] elf: Add la_activity during application exit jma14
2021-12-27 13:20 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).