summaryrefslogtreecommitdiffstats
path: root/runtime/utils.cc
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-09-18 20:56:04 -0700
committerAndreas Gampe <agampe@google.com>2014-09-18 23:43:07 -0700
commit3c13a794845e0cf7887e33b2ec20de7e6ba85f8f (patch)
treeab9a9a426a371de0c32e48a85fdda44a321a06a0 /runtime/utils.cc
parent5cdd0734d2f79eedc530f5f1e876cd2110e29c86 (diff)
downloadart-3c13a794845e0cf7887e33b2ec20de7e6ba85f8f.tar.gz
art-3c13a794845e0cf7887e33b2ec20de7e6ba85f8f.tar.bz2
art-3c13a794845e0cf7887e33b2ec20de7e6ba85f8f.zip
ART: Only allow the zygote to create the global boot image
Do not allow arbitrary processes, even when root, to write the boot image in /data/dalvik-cache. Bug: 17478752, 17510489, 17439961 Change-Id: Iba2b74be6d0752f4221f4ff5ee295b45a34cb2e1 (cherry picked from commit 33c36d4f22ab6a5e61eb47b654deaf647c34e49c)
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r--runtime/utils.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc
index 6135e5d84..9157f6c9b 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1232,13 +1232,14 @@ const char* GetAndroidDataSafe(std::string* error_msg) {
}
void GetDalvikCache(const char* subdir, const bool create_if_absent, std::string* dalvik_cache,
- bool* have_android_data, bool* dalvik_cache_exists) {
+ bool* have_android_data, bool* dalvik_cache_exists, bool* is_global_cache) {
CHECK(subdir != nullptr);
std::string error_msg;
const char* android_data = GetAndroidDataSafe(&error_msg);
if (android_data == nullptr) {
*have_android_data = false;
*dalvik_cache_exists = false;
+ *is_global_cache = false;
return;
} else {
*have_android_data = true;
@@ -1246,7 +1247,8 @@ void GetDalvikCache(const char* subdir, const bool create_if_absent, std::string
const std::string dalvik_cache_root(StringPrintf("%s/dalvik-cache/", android_data));
*dalvik_cache = dalvik_cache_root + subdir;
*dalvik_cache_exists = OS::DirectoryExists(dalvik_cache->c_str());
- if (create_if_absent && !*dalvik_cache_exists && strcmp(android_data, "/data") != 0) {
+ *is_global_cache = strcmp(android_data, "/data") == 0;
+ if (create_if_absent && !*dalvik_cache_exists && !*is_global_cache) {
// Don't create the system's /data/dalvik-cache/... because it needs special permissions.
*dalvik_cache_exists = ((mkdir(dalvik_cache_root.c_str(), 0700) == 0 || errno == EEXIST) &&
(mkdir(dalvik_cache->c_str(), 0700) == 0 || errno == EEXIST));