dlfcn: dlerror needs to call free from the base namespace [BZ #24773]
authorFlorian Weimer <fweimer@redhat.com>
Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)
commitfada9018199c21c469ff0e731ef75c6020074ac9
tree92a5914178f7acac985fd4ce15d4e7ee99522e9d
parentb2964eb1d9a6b8ab1250e8a881cf406182da5875
dlfcn: dlerror needs to call free from the base namespace [BZ #24773]

Calling free directly may end up freeing a pointer allocated by the
dynamic loader using malloc from libc.so in the base namespace using
the allocator from libc.so in a secondary namespace, which results in
crashes.

This commit redirects the free call through GLRO and the dynamic
linker, to reach the correct namespace.  It also cleans up the dlerror
handling along the way, so that pthread_setspecific is no longer
needed (which avoids triggering bug 24774).
14 files changed:
dlfcn/Makefile
dlfcn/Versions
dlfcn/dlerror.c
dlfcn/dlerror.h [new file with mode: 0644]
dlfcn/dlfreeres.c [deleted file]
dlfcn/libc_dlerror_result.c [new file with mode: 0644]
elf/dl-exception.c
elf/rtld.c
elf/tst-dlmopen-dlerror-mod.c
elf/tst-dlmopen-dlerror.c
include/dlfcn.h
malloc/set-freeres.c
malloc/thread-freeres.c
sysdeps/generic/ldsodefs.h