Merge "Explicitly enable greylist for classloader-namespaces"
This commit is contained in:
commit
2f2cd76d4d
2 changed files with 20 additions and 2 deletions
|
|
@ -55,6 +55,12 @@ enum {
|
||||||
* permitted_path from the caller's namespace.
|
* permitted_path from the caller's namespace.
|
||||||
*/
|
*/
|
||||||
ANDROID_NAMESPACE_TYPE_SHARED = 2,
|
ANDROID_NAMESPACE_TYPE_SHARED = 2,
|
||||||
|
|
||||||
|
/* This flag instructs linker to enable grey-list workaround for the namespace.
|
||||||
|
* See http://b/26394120 for details.
|
||||||
|
*/
|
||||||
|
ANDROID_NAMESPACE_TYPE_GREYLIST_ENABLED = 0x08000000,
|
||||||
|
|
||||||
ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED = ANDROID_NAMESPACE_TYPE_SHARED |
|
ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED = ANDROID_NAMESPACE_TYPE_SHARED |
|
||||||
ANDROID_NAMESPACE_TYPE_ISOLATED,
|
ANDROID_NAMESPACE_TYPE_ISOLATED,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ class LibraryNamespaces {
|
||||||
LibraryNamespaces() : initialized_(false) { }
|
LibraryNamespaces() : initialized_(false) { }
|
||||||
|
|
||||||
bool Create(JNIEnv* env,
|
bool Create(JNIEnv* env,
|
||||||
|
uint32_t target_sdk_version,
|
||||||
jobject class_loader,
|
jobject class_loader,
|
||||||
bool is_shared,
|
bool is_shared,
|
||||||
jstring java_library_path,
|
jstring java_library_path,
|
||||||
|
|
@ -141,6 +142,10 @@ class LibraryNamespaces {
|
||||||
namespace_type |= ANDROID_NAMESPACE_TYPE_SHARED;
|
namespace_type |= ANDROID_NAMESPACE_TYPE_SHARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target_sdk_version < 24) {
|
||||||
|
namespace_type |= ANDROID_NAMESPACE_TYPE_GREYLIST_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
NativeLoaderNamespace parent_ns;
|
NativeLoaderNamespace parent_ns;
|
||||||
bool found_parent_namespace = FindParentNamespaceByClassLoader(env, class_loader, &parent_ns);
|
bool found_parent_namespace = FindParentNamespaceByClassLoader(env, class_loader, &parent_ns);
|
||||||
|
|
||||||
|
|
@ -397,12 +402,12 @@ jstring CreateClassLoaderNamespace(JNIEnv* env,
|
||||||
jstring library_path,
|
jstring library_path,
|
||||||
jstring permitted_path) {
|
jstring permitted_path) {
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
UNUSED(target_sdk_version);
|
|
||||||
std::lock_guard<std::mutex> guard(g_namespaces_mutex);
|
std::lock_guard<std::mutex> guard(g_namespaces_mutex);
|
||||||
|
|
||||||
std::string error_msg;
|
std::string error_msg;
|
||||||
NativeLoaderNamespace ns;
|
NativeLoaderNamespace ns;
|
||||||
bool success = g_namespaces->Create(env,
|
bool success = g_namespaces->Create(env,
|
||||||
|
target_sdk_version,
|
||||||
class_loader,
|
class_loader,
|
||||||
is_shared,
|
is_shared,
|
||||||
library_path,
|
library_path,
|
||||||
|
|
@ -439,7 +444,14 @@ void* OpenNativeLibrary(JNIEnv* env,
|
||||||
if (!g_namespaces->FindNamespaceByClassLoader(env, class_loader, &ns)) {
|
if (!g_namespaces->FindNamespaceByClassLoader(env, class_loader, &ns)) {
|
||||||
// This is the case where the classloader was not created by ApplicationLoaders
|
// This is the case where the classloader was not created by ApplicationLoaders
|
||||||
// In this case we create an isolated not-shared namespace for it.
|
// In this case we create an isolated not-shared namespace for it.
|
||||||
if (!g_namespaces->Create(env, class_loader, false, library_path, nullptr, &ns, error_msg)) {
|
if (!g_namespaces->Create(env,
|
||||||
|
target_sdk_version,
|
||||||
|
class_loader,
|
||||||
|
false,
|
||||||
|
library_path,
|
||||||
|
nullptr,
|
||||||
|
&ns,
|
||||||
|
error_msg)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue