dlmopen with RTLD_GLOBAL

Florian Weimer fweimer@redhat.com
Tue Jul 4 09:50:00 GMT 2017


On 07/03/2017 08:37 PM, Elliott Slaughter wrote:
> On Mon, Jul 3, 2017 at 11:27 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 06/30/2017 11:52 PM, Elliott Slaughter wrote:
>>> main:
>>>   dlmopen(LM_ID_NEWLM, "libpython2.7.so", RTLD_DEEPBIND | RTLD_LOCAL |
>>> RTLD_LAZY)
>>>   from inside user Python script:
>>>     import some_native_module
>>>     this causes Python to execute the following (remember this is
>>> inside the new namespace):
>>>       dlopen("some_native_module.so", ...)
>>>
>>> If RTLD_GLOBAL is an option with dlmopen, then the symbols can be
>>> exposed within the new namespace, and subsequent dlopen calls to
>>> shared objects that do not explicitly mention Python will succeed.
>>
>> What happens if you reload libpython2.7.so with RTLD_GLOBAL within the
>> namespace?
> 
> I believe there is an outstanding bug for that:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=18684

Oh.  So there is no quick way to test what you are intending to do.

My hunch is that what you are trying to do will not give you reliable
interpreter isolation.  I'd look at improving the Python support for
sub-interpreters, so that they won't need a global (per-process) lock
anymore (subject to a few additional conditions).

Thanks,
Florian



More information about the Libc-help mailing list