This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v4 0/3] elf: Allow dlopen of filter object to work [BZ #16272]


Glibc currently supports filter objects (shared libraries compiled
with -Wl,--filter or -Wl,--auxiliary) by inserting the filtee ahead of
the filter object in the search path. This works for the case where
the application is linked against the filter object.

When the application tries to use dlopen to load the filter object,
glibc currently fails with:

Inconsistency detected by ld.so: dl-deps.c: 574: _dl_map_object_deps:
Assertion `map->l_searchlist.r_list[0] == map' failed!

This fails because dl_map_object_deps assumes that the library being
loaded is at the head of the search list.

The filtee object also needs to be relocated when dlopen is used.

The first patch attempts to address these in a minimal way, and adds
simple test cases for filter and auxiliary objects.

The follow up patches do some cleanup. If we can use l_initfini to do
the relocations, then the call to _dl_sort_maps is redundant. Once
that is removed there is no need for the stack allocation of map.

Outstanding issues/concerns from previous patchset reviews:

 - Florian points out that for this use case, the standard way to do
   API filtering is to have a linker script, and setup the soname and
   symlinks to point to the implementation library.   
   See thread at https://sourceware.org/ml/libc-alpha/2019-10/msg00636.html

   This should work. The install is a bit more complicated than just
   copying the library to the right place. I'd still like to fix the
   filter objects though...

 - Adhemerval pointed out that the code that removes relocation
   dependencies is not tested by the testcase in patchset 3. This is
   still the case, as I haven't been able to trigger this.
   See thread at https://sourceware.org/ml/libc-alpha/2020-01/msg00481.html

v4:
 - update copyrights to 2020
 - extend testing to cover auxiliary filter objects
 - switch a series of memcpy calls into loops to copy pointers
 - calculate map_index during earlier for loop
 - add missing file descriptions
 - update sort description

v3:
https://sourceware.org/ml/libc-alpha/2019-12/msg00099.html
 - rebased for changes in elf/Makefile
 - updates to commit messages

v2:
https://sourceware.org/ml/libc-alpha/2019-10/msg00698.html
 - code formatting fixups
 - add dependency of test output on filtee library
 - tests changed to use the test framework

v1:
https://sourceware.org/ml/libc-alpha/2019-10/msg00519.html

David Kilroy (3):
  elf: Allow dlopen of filter object to work [BZ #16272]
  elf: avoid redundant sort in dlopen
  elf: avoid stack allocation in dl_open_worker

 elf/Makefile               | 18 ++++++++++++++++--
 elf/dl-deps.c              | 39 ++++++++++++++++++++++++++++----------
 elf/dl-open.c              | 39 +++++++++++++++++++-------------------
 elf/tst-auxobj-dlopen.c    | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 elf/tst-auxobj.c           | 42 +++++++++++++++++++++++++++++++++++++++++
 elf/tst-filterobj-aux.c    | 33 ++++++++++++++++++++++++++++++++
 elf/tst-filterobj-dlopen.c | 39 ++++++++++++++++++++++++++++++++++++++
 elf/tst-filterobj-filtee.c | 27 ++++++++++++++++++++++++++
 elf/tst-filterobj-filtee.h | 24 +++++++++++++++++++++++
 elf/tst-filterobj-flt.c    | 27 ++++++++++++++++++++++++++
 elf/tst-filterobj.c        | 36 +++++++++++++++++++++++++++++++++++
 11 files changed, 339 insertions(+), 32 deletions(-)
 create mode 100644 elf/tst-auxobj-dlopen.c
 create mode 100644 elf/tst-auxobj.c
 create mode 100644 elf/tst-filterobj-aux.c
 create mode 100644 elf/tst-filterobj-dlopen.c
 create mode 100644 elf/tst-filterobj-filtee.c
 create mode 100644 elf/tst-filterobj-filtee.h
 create mode 100644 elf/tst-filterobj-flt.c
 create mode 100644 elf/tst-filterobj.c

-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]