android_get_exported_namespace: acquire g_dl_mutex

android_get_exported_namespace searches g_exported_namespaces, which
isn't modified after process initialization, but it does the search
using a new std::string object, and the linker's malloc/free functions
aren't thread-safe. (They're protected by the same lock (g_dl_mutex) as
the rest of the linker's state.)

Bug: http://b/150372650
Test: bionic-unit-tests
Change-Id: Iafd12e5ab36ae61f0642aad59939f528d31bda16
This commit is contained in:
Ryan Prichard 2020-04-20 17:59:18 -07:00
parent 0361a4f867
commit c2a93792fc

View file

@ -279,6 +279,7 @@ bool __loader_android_link_namespaces_all_libs(android_namespace_t* namespace_fr
}
android_namespace_t* __loader_android_get_exported_namespace(const char* name) {
ScopedPthreadMutexLocker locker(&g_dl_mutex);
return get_exported_namespace(name);
}