[PATCH][BZ #17833] _dl_close_worker() does not release inconsistent objects.
Pavel Kopyl
p.kopyl@samsung.com
Mon Jan 19 18:39:00 GMT 2015
Hello,
I faced with the following problem. [See test case:
https://sourceware.org/bugzilla/show_bug.cgi?id=17833]
I've a shared library that contains both undefined and unique symbols.
Then I try to call the following sequence of dlopen:
1. dlopen("./libfoo.so", RTLD_NOW)
2. dlopen("./libfoo.so", RTLD_LAZY | RTLD_GLOBAL)
First dlopen call terminates with error because of undefined symbols,
but STB_GNU_UNIQUE ones set DF_1_NODELETE flag and hence block library
in the memory.
The library goes into inconsistent state as several structures remain
uninitialized. For instance, relocations for GOT table were not performed.
By the time of second dlopen call this library looks like as it would be
fully initialized but this is not true: any call through incorrect GOT
table leads to segmentation fault.
On some systems this inconsistency triggers assertions in the dynamic
linker.
Suggested patch forces object deletion in case of dlopen() fail:
1. Clears DF_1_NODELETE flag if dlopen() fails, allowing library to be
deleted from memory.
2. For each unique symbol that is defined in this object clears
appropriate entry in _ns_unique_sym_table.
Thanks
Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: delete_inconsistent_objs.patch
Type: text/x-patch
Size: 3237 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150119/370b479e/attachment.bin>
More information about the Libc-alpha
mailing list