mbox series

[RFC,v2,0/6] Proof-of-Concept implementation of RTLD_SHARED for dlmopen

Message ID 20180606181934.2480-1-vivek@collabora.com
Headers show
Series Proof-of-Concept implementation of RTLD_SHARED for dlmopen | expand

Message

Vivek Dasmohapatra June 6, 2018, 6:19 p.m. UTC
As discussed in https://sourceware.org/bugzilla/show_bug.cgi?id=22745
dlmopen requires a mechanism for [optionally] sharing some objects
between more than one namespace.

The following patchset attempts an implementation for this: If an object
is loaded with the new RTLD_SHARED flag we instead ensure that a "master"
copy exists (and is flagged as no-delete) in the main namespace and a
thin wrapper or clone is placed in the target namespace.

I have attached the test program(s) I am using to the bug above.

This patch series should address all the comments received on the previous
(v1) series.

If this is acceptable then I will get to work on a second patch series
extending this one, which will aim to achieve the following:

 - dlmopen will implicitly apply RTLD_SHARED to the libc/libpthread group

 - The user will be able to request that this sharing _not_ occur
   by passing a different flag to dlmopen (name TBD)

 - LD_AUDIT paths will not apply this implict sharing rule, so audit libraries
   will continue to be completely isolated.

And further (probably in another series to keep the changes manageable):

 - Implement RTLD_GLOBAL support for namespaces (ie RTLD_GLOBAL will mean
   "this DSO should be used for all symbol resolution in _this_ namespace")

Vivek Das Mohapatra (6):
  Declare and describe the dlmopen RTLD_SHARED flag
  include/link.h: Update the link_map struct to allow proxies
  elf/dl-object.c: Implement a helper function to proxy link_map entries
  elf/dl-load.c, elf-dl-open.c: Implement RTLD_SHARED dlmopen proxying
  elf/dl-fini.c: Handle proxy link_map entries in the shutdown path
  elf/dl-init.c: Skip proxied link map entries in the dl init path

 bits/dlfcn.h               |  7 ++++
 elf/dl-close.c             | 43 +++++++++++++----------
 elf/dl-fini.c              |  6 ++--
 elf/dl-init.c              |  4 +--
 elf/dl-load.c              | 45 ++++++++++++++++++++++++
 elf/dl-object.c            | 85 ++++++++++++++++++++++++++++++++++++++++++++++
 elf/dl-open.c              | 39 +++++++++++++++++++--
 include/link.h             |  6 ++--
 sysdeps/generic/ldsodefs.h |  5 +++
 sysdeps/mips/bits/dlfcn.h  |  7 ++++
 10 files changed, 222 insertions(+), 25 deletions(-)