Merge "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""
This commit is contained in:
commit
73ee7a6320
|
@ -91,21 +91,19 @@ static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
|
||||||
static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
|
static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
static const char* const kSystemLibDir = "/system/lib64";
|
static const char* const kSystemLibDir = "/system/lib64";
|
||||||
static const char* const kOdmLibDir = "/odm/lib64";
|
static const char* const kOdmLibDir = "/odm/lib64";
|
||||||
static const char* const kVendorLibDir = "/vendor/lib64";
|
static const char* const kVendorLibDir = "/vendor/lib64";
|
||||||
static const char* const kAsanSystemLibDir = "/data/asan/system/lib64";
|
static const char* const kAsanSystemLibDir = "/data/asan/system/lib64";
|
||||||
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib64";
|
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib64";
|
||||||
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib64";
|
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib64";
|
||||||
static const char* const kRuntimeApexLibDir = "/apex/com.android.runtime/lib64";
|
|
||||||
#else
|
#else
|
||||||
static const char* const kSystemLibDir = "/system/lib";
|
static const char* const kSystemLibDir = "/system/lib";
|
||||||
static const char* const kOdmLibDir = "/odm/lib";
|
static const char* const kOdmLibDir = "/odm/lib";
|
||||||
static const char* const kVendorLibDir = "/vendor/lib";
|
static const char* const kVendorLibDir = "/vendor/lib";
|
||||||
static const char* const kAsanSystemLibDir = "/data/asan/system/lib";
|
static const char* const kAsanSystemLibDir = "/data/asan/system/lib";
|
||||||
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib";
|
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib";
|
||||||
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib";
|
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib";
|
||||||
static const char* const kRuntimeApexLibDir = "/apex/com.android.runtime/lib";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* const kAsanLibDirPrefix = "/data/asan";
|
static const char* const kAsanLibDirPrefix = "/data/asan";
|
||||||
|
@ -230,44 +228,6 @@ static bool is_greylisted(android_namespace_t* ns, const char* name, const soinf
|
||||||
}
|
}
|
||||||
// END OF WORKAROUND
|
// END OF WORKAROUND
|
||||||
|
|
||||||
// Workaround for dlopen(/system/lib(64)/<soname>) when .so is in /apex. http://b/121248172
|
|
||||||
/**
|
|
||||||
* Translate /system path to /apex path if needed
|
|
||||||
* The workaround should work only when targetSdkVersion < Q.
|
|
||||||
*
|
|
||||||
* param out_name_to_apex pointing to /apex path
|
|
||||||
* return true if translation is needed
|
|
||||||
*/
|
|
||||||
static bool translateSystemPathToApexPath(const char* name, std::string* out_name_to_apex) {
|
|
||||||
static const char* const kSystemToRuntimeApexLibs[] = {
|
|
||||||
"libicuuc.so",
|
|
||||||
"libicui18n.so",
|
|
||||||
};
|
|
||||||
// New mapping for new apex should be added below
|
|
||||||
|
|
||||||
// Nothing to do if target sdk version is Q or above
|
|
||||||
if (get_application_target_sdk_version() >= __ANDROID_API_Q__) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the path is not absolute, or isn't /system/lib, there's nothing to do.
|
|
||||||
if (name[0] != '/' || dirname(name).compare(kSystemLibDir) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* base_name = basename(name);
|
|
||||||
|
|
||||||
for (const char* soname : kSystemToRuntimeApexLibs) {
|
|
||||||
if (strcmp(base_name, soname) == 0) {
|
|
||||||
*out_name_to_apex = std::string(kRuntimeApexLibDir) + "/" + base_name;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// End Workaround for dlopen(/system/lib/<soname>) when .so is in /apex.
|
|
||||||
|
|
||||||
static std::vector<std::string> g_ld_preload_names;
|
static std::vector<std::string> g_ld_preload_names;
|
||||||
|
|
||||||
static bool g_anonymous_namespace_initialized;
|
static bool g_anonymous_namespace_initialized;
|
||||||
|
@ -2114,14 +2074,13 @@ void* do_dlopen(const char* name, int flags,
|
||||||
android_namespace_t* ns = get_caller_namespace(caller);
|
android_namespace_t* ns = get_caller_namespace(caller);
|
||||||
|
|
||||||
LD_LOG(kLogDlopen,
|
LD_LOG(kLogDlopen,
|
||||||
"dlopen(name=\"%s\", flags=0x%x, extinfo=%s, caller=\"%s\", caller_ns=%s@%p, targetSdkVersion=%i) ...",
|
"dlopen(name=\"%s\", flags=0x%x, extinfo=%s, caller=\"%s\", caller_ns=%s@%p) ...",
|
||||||
name,
|
name,
|
||||||
flags,
|
flags,
|
||||||
android_dlextinfo_to_string(extinfo).c_str(),
|
android_dlextinfo_to_string(extinfo).c_str(),
|
||||||
caller == nullptr ? "(null)" : caller->get_realpath(),
|
caller == nullptr ? "(null)" : caller->get_realpath(),
|
||||||
ns == nullptr ? "(null)" : ns->get_name(),
|
ns == nullptr ? "(null)" : ns->get_name(),
|
||||||
ns,
|
ns);
|
||||||
get_application_target_sdk_version());
|
|
||||||
|
|
||||||
auto purge_guard = android::base::make_scope_guard([&]() { purge_unused_memory(); });
|
auto purge_guard = android::base::make_scope_guard([&]() { purge_unused_memory(); });
|
||||||
|
|
||||||
|
@ -2155,28 +2114,6 @@ void* do_dlopen(const char* name, int flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for dlopen(/system/lib/<soname>) when .so is in /apex. http://b/121248172
|
|
||||||
// The workaround works only when targetSdkVersion < Q.
|
|
||||||
std::string name_to_apex;
|
|
||||||
if (translateSystemPathToApexPath(name, &name_to_apex)) {
|
|
||||||
const char* new_name = name_to_apex.c_str();
|
|
||||||
LD_LOG(kLogDlopen, "dlopen translating path to /apex: name=%s newName=%s",
|
|
||||||
name,
|
|
||||||
new_name);
|
|
||||||
// Some APEXs could be optionally disabled. Only translate the path
|
|
||||||
// when the old file is absent and the new file exists.
|
|
||||||
if (file_exists(name)) {
|
|
||||||
LD_LOG(kLogDlopen, "dlopen failed to translate path to /apex: /system file exists. %s", name);
|
|
||||||
} else if (!file_exists(new_name)) {
|
|
||||||
LD_LOG(kLogDlopen, "dlopen failed to translate path to /apex: /apex file does not exist. %s",
|
|
||||||
new_name);
|
|
||||||
} else {
|
|
||||||
LD_LOG(kLogDlopen, "dlopen new path to /apex: newName=%s", new_name);
|
|
||||||
name = new_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// End Workaround for dlopen(/system/lib/<soname>) when .so is in /apex.
|
|
||||||
|
|
||||||
std::string asan_name_holder;
|
std::string asan_name_holder;
|
||||||
|
|
||||||
const char* translated_name = name;
|
const char* translated_name = name;
|
||||||
|
|
Loading…
Reference in New Issue