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

Message ID cover.1571301957.git.david.kilroy@arm.com
Headers show
Series
  • elf: Allow dlopen of filter object to work [BZ #16272]
Related show

Message

David Kilroy Oct. 17, 2019, 10:33 a.m.
Glibc currently supports filter objects (shared libraries compiled
with -Wl,--filter) 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 a
test case verify the fix.

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.

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               | 12 +++++++++--
 elf/dl-deps.c              | 35 ++++++++++++++++++++++--------
 elf/dl-open.c              | 32 +++++++++++++--------------
 elf/tst-filterobj-dlopen.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 elf/tst-filterobj-flt.c    | 24 +++++++++++++++++++++
 elf/tst-filterobj-lib.c    | 24 +++++++++++++++++++++
 elf/tst-filterobj-lib.h    | 18 ++++++++++++++++
 elf/tst-filterobj.c        | 34 +++++++++++++++++++++++++++++
 8 files changed, 205 insertions(+), 28 deletions(-)
 create mode 100644 elf/tst-filterobj-dlopen.c
 create mode 100644 elf/tst-filterobj-flt.c
 create mode 100644 elf/tst-filterobj-lib.c
 create mode 100644 elf/tst-filterobj-lib.h
 create mode 100644 elf/tst-filterobj.c

-- 
2.7.4