Load /data oat/odex files non-executable when only_use_system_oat_files is set.
Make it still ok to use the vdex and the class status in the oat file.
This means:
- If dex code is uncompressed in APK we'll use that
- If dex code is compressed in APK, we'll use the dex code in the vdex.
This is a temporary solution in order to almost mimic performance-wise what
full stack integrity wants to achieve (priv-apps running from verified,
uncompressed dex code in APK).
This is to assess the impact of full stack integrity on privileged apps.
This CL doesn't ensure any integrity, and doesn't check whether the vdex has
been "tainted".
bug: 30972906
Change-Id: If0a6ab26dd6211290db53b7f02d88d45aff68c0c
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index a98da0f..50f5e7a 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -246,6 +246,7 @@
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
false,
+ false,
vdex_fd.get(),
odex_fd.get(),
zip_fd.get());
@@ -285,6 +286,7 @@
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
false,
+ false,
vdex_fd.get(),
-1 /* oat_fd */,
zip_fd.get());
@@ -319,6 +321,7 @@
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
false,
+ false,
-1 /* vdex_fd */,
odex_fd.get(),
zip_fd.get());
@@ -342,6 +345,7 @@
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
false,
+ false,
-1 /* vdex_fd */,
-1 /* oat_fd */,
zip_fd);
@@ -1439,6 +1443,60 @@
default_filter, false, false, relative_context.get()));
}
+TEST_F(OatFileAssistantTest, SystemOdex) {
+ std::string dex_location = GetScratchDir() + "/OatUpToDate.jar";
+ std::string odex_location = GetScratchDir() + "/OatUpToDate.odex";
+ std::string system_location = GetAndroidRoot() + "/OatUpToDate.jar";
+
+ std::string error_msg;
+
+ Copy(GetDexSrc1(), dex_location);
+ EXPECT_FALSE(LocationIsOnSystem(dex_location.c_str()));
+
+ {
+ OatFileAssistant oat_file_assistant(dex_location.c_str(),
+ kRuntimeISA,
+ true,
+ false);
+ int status = oat_file_assistant.MakeUpToDate(false, kSpecialSharedLibraryContext, &error_msg);
+ EXPECT_EQ(OatFileAssistant::kUpdateSucceeded, status) << error_msg;
+ EXPECT_TRUE(oat_file_assistant.GetBestOatFile()->IsExecutable());
+ }
+
+ {
+ OatFileAssistant oat_file_assistant(dex_location.c_str(),
+ kRuntimeISA,
+ true,
+ true);
+ int status = oat_file_assistant.MakeUpToDate(false, kSpecialSharedLibraryContext, &error_msg);
+ EXPECT_EQ(OatFileAssistant::kUpdateSucceeded, status) << error_msg;
+ EXPECT_FALSE(oat_file_assistant.GetBestOatFile()->IsExecutable());
+ }
+
+ Copy(GetDexSrc1(), system_location);
+ EXPECT_TRUE(LocationIsOnSystem(system_location.c_str()));
+
+ {
+ OatFileAssistant oat_file_assistant(system_location.c_str(),
+ kRuntimeISA,
+ true,
+ false);
+ int status = oat_file_assistant.MakeUpToDate(false, kSpecialSharedLibraryContext, &error_msg);
+ EXPECT_EQ(OatFileAssistant::kUpdateSucceeded, status) << error_msg;
+ EXPECT_TRUE(oat_file_assistant.GetBestOatFile()->IsExecutable());
+ }
+
+ {
+ OatFileAssistant oat_file_assistant(system_location.c_str(),
+ kRuntimeISA,
+ true,
+ true);
+ int status = oat_file_assistant.MakeUpToDate(false, kSpecialSharedLibraryContext, &error_msg);
+ EXPECT_EQ(OatFileAssistant::kUpdateSucceeded, status) << error_msg;
+ EXPECT_TRUE(oat_file_assistant.GetBestOatFile()->IsExecutable());
+ }
+}
+
// TODO: More Tests:
// * Test class linker falls back to unquickened dex for DexNoOat
// * Test class linker falls back to unquickened dex for MultiDexNoOat