|
Message-ID: <96c367533236e3e203f04a994ee65c47@ispras.ru> Date: Thu, 07 Feb 2019 00:23:06 +0300 From: Alexey Izbyshev <izbyshev@...ras.ru> To: Markus Wichmann <nullplan@....net> Cc: musl@...ts.openwall.com Subject: Re: dlsym(handle) may search in unrelated libraries On 2019-02-06 23:25, Markus Wichmann wrote: > Right you are. It took me a while to understand what the deps array was > even for (since musl's dlclose() doesn't do anything, tracking > dependencies is mostly pointless), but I found it is needed for lazy > relocation processing. So it is necessary for all libs opened by > dlopen() directly to contain a list of all their dependencies. All the > other libs can have an empty list. Actually, dso->deps is used in dlsym(handle) because it must use the dependency order for symbol search, so it's incorrect to have deps empty for "all the other" libs. Consider the following modification of my previous example: $ cat bazdep.c int bazdep = 1; extern int bazdepdep; int *p = &bazdepdep; $ cat bazdepdep.c int bazdepdep = 2; $ cat main.c #include <dlfcn.h> #include <stdio.h> int main(void) { if (!dlopen("libbaz.so", RTLD_NOW|RTLD_LOCAL)) return 1; if (!dlopen("libfoo.so", RTLD_NOW|RTLD_LOCAL)) return 1; void *h = dlopen("libbazdep.so", RTLD_NOW|RTLD_LOCAL); printf("%p\n", dlsym(h, "bar")); printf("%p\n", dlsym(h, "bazdepdep")); } The correct output is zero in the first line and some non-zero address in the second. Vanilla musl 1.1.21 prints two non-zero addresses. But with your patch the output is two zeros because dlsym() can't search in dependencies of "libbazdep.so" anymore. Alexey
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.