Extend white-listed directories to include /mnt/expand
am: f334cbf0e1
* commit 'f334cbf0e1425633bef96a21b0ce9e30f4c6ffa9':
Extend white-listed directories to include /mnt/expand
Change-Id: I378ed0ea80684585ca7daa833b91336a8d38c98c
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 5c1db5b..0b49b41 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -40,6 +40,11 @@
static constexpr const char* kPublicNativeLibrariesSystemConfigPathFromRoot = "/etc/public.libraries.txt";
static constexpr const char* kPublicNativeLibrariesVendorConfig = "/vendor/etc/public.libraries.txt";
+// (http://b/27588281) This is a workaround for apps using custom classloaders and calling
+// System.load() with an absolute path which is outside of the classloader library search path.
+// This list includes all directories app is allowed to access this way.
+static constexpr const char* kWhitelistedDirectories = "/data:/mnt/expand";
+
static bool is_debuggable() {
char debuggable[PROP_VALUE_MAX];
property_get("ro.debuggable", debuggable, "0");
@@ -63,18 +68,17 @@
library_path = library_path_utf_chars.c_str();
}
- std::string permitted_path;
+ // (http://b/27588281) This is a workaround for apps using custom
+ // classloaders and calling System.load() with an absolute path which
+ // is outside of the classloader library search path.
+ //
+ // This part effectively allows such a classloader to access anything
+ // under /data and /mnt/expand
+ std::string permitted_path = kWhitelistedDirectories;
+
if (java_permitted_path != nullptr) {
ScopedUtfChars path(env, java_permitted_path);
- permitted_path = path.c_str();
- } else {
- // (http://b/27588281) This is a workaround for apps using custom
- // classloaders and calling System.load() with an absolute path which
- // is outside of the classloader library search path.
- //
- // This part effectively allows such a classloader to access anything
- // under /data
- permitted_path = "/data";
+ permitted_path = permitted_path + ":" + path.c_str();
}
if (!initialized_ && !InitPublicNamespace(library_path.c_str(), target_sdk_version)) {