diff options
author | 2018-02-27 17:26:11 +0000 | |
---|---|---|
committer | 2018-02-27 17:26:11 +0000 | |
commit | a19b7649faf8780737be7ce3ec48a12d81c6d69f (patch) | |
tree | a96372834531ab26b0fae78ce9ef4fecac3ef2c1 | |
parent | d6f914ea4bd09f2d60db2783f7a3fd93d3ec0afb (diff) |
Revert "Full-stack integrity: check vdex contents."
bug: 30972906
Test fails on device.
This reverts commit d6f914ea4bd09f2d60db2783f7a3fd93d3ec0afb.
Change-Id: I53902b0d6d4dbe8237f61bf01542acf538229c71
-rw-r--r-- | compiler/compiler.h | 6 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 7 | ||||
-rw-r--r-- | dex2oat/dex2oat_options.cc | 7 | ||||
-rw-r--r-- | dex2oat/dex2oat_options.def | 2 | ||||
-rw-r--r-- | dex2oat/linker/image_test.h | 2 | ||||
-rw-r--r-- | dex2oat/linker/oat_writer.cc | 9 | ||||
-rw-r--r-- | dex2oat/linker/oat_writer.h | 6 | ||||
-rw-r--r-- | dex2oat/linker/oat_writer_test.cc | 2 | ||||
-rw-r--r-- | libdexfile/dex/dex_file_loader.cc | 10 | ||||
-rw-r--r-- | libdexfile/dex/dex_file_loader.h | 3 | ||||
-rw-r--r-- | runtime/dex/art_dex_file_loader.cc | 13 | ||||
-rw-r--r-- | runtime/dex/art_dex_file_loader.h | 3 | ||||
-rw-r--r-- | runtime/oat_file_assistant.cc | 15 | ||||
-rw-r--r-- | runtime/oat_file_assistant.h | 3 | ||||
-rw-r--r-- | runtime/parsed_options.cc | 2 | ||||
-rw-r--r-- | runtime/runtime.cc | 5 | ||||
-rw-r--r-- | runtime/runtime_options.def | 2 | ||||
-rwxr-xr-x | test/677-fsi/build | 17 | ||||
-rw-r--r-- | test/677-fsi/check | 23 | ||||
-rw-r--r-- | test/677-fsi/expected.txt | 3 | ||||
-rw-r--r-- | test/677-fsi/info.txt | 0 | ||||
-rw-r--r-- | test/677-fsi/run | 17 | ||||
-rw-r--r-- | test/677-fsi/src/Main.java | 21 | ||||
-rw-r--r-- | test/knownfailures.json | 5 |
24 files changed, 23 insertions, 160 deletions
diff --git a/compiler/compiler.h b/compiler/compiler.h index a17e2b5875..b92bff61a9 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -39,12 +39,6 @@ template<class T> class Handle; class OatWriter; class Thread; -enum class CopyOption { - kNever, - kAlways, - kOnlyIfCompressed -}; - class Compiler { public: enum Kind { diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index df874bc397..b5c5e4566d 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -456,7 +456,7 @@ NO_RETURN static void Usage(const char* fmt, ...) { UsageError(" --deduplicate-code=true|false: enable|disable code deduplication. Deduplicated"); UsageError(" code will have an arbitrary symbol tagged with [DEDUPED]."); UsageError(""); - UsageError(" --copy-dex-files=true|false: enable|disable copying the dex files into the"); + UsageError(" --copying-dex-files=true|false: enable|disable copying the dex files into the"); UsageError(" output vdex."); UsageError(""); UsageError(" --compilation-reason=<string>: optional metadata specifying the reason for"); @@ -2920,9 +2920,8 @@ class Dex2Oat FINAL { // Whether the given input vdex is also the output. bool update_input_vdex_ = false; - // By default, copy the dex to the vdex file only if dex files are - // compressed in APK. - CopyOption copy_dex_files_ = CopyOption::kOnlyIfCompressed; + // By default, copy the dex to the vdex file. + bool copy_dex_files_ = true; // The reason for invoking the compiler. std::string compilation_reason_; diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc index 0d68f4fab6..1ef100df08 100644 --- a/dex2oat/dex2oat_options.cc +++ b/dex2oat/dex2oat_options.cc @@ -234,10 +234,9 @@ static Parser CreateArgumentParser() { .Define("--force-determinism") .IntoKey(M::ForceDeterminism) .Define("--copy-dex-files=_") - .WithType<CopyOption>() - .WithValueMap({{"true", CopyOption::kOnlyIfCompressed}, - {"false", CopyOption::kNever}, - {"always", CopyOption::kAlways}}) + .WithType<bool>() + .WithValueMap({{"true", false}, + {"false", false}}) .IntoKey(M::CopyDexFiles) .Define("--classpath-dir=_") .WithType<std::string>() diff --git a/dex2oat/dex2oat_options.def b/dex2oat/dex2oat_options.def index 01f9d9425f..a9d349bd08 100644 --- a/dex2oat/dex2oat_options.def +++ b/dex2oat/dex2oat_options.def @@ -74,7 +74,7 @@ DEX2OAT_OPTIONS_KEY (Unit, Host) DEX2OAT_OPTIONS_KEY (Unit, DumpTiming) DEX2OAT_OPTIONS_KEY (Unit, DumpPasses) DEX2OAT_OPTIONS_KEY (Unit, DumpStats) -DEX2OAT_OPTIONS_KEY (CopyOption, CopyDexFiles) +DEX2OAT_OPTIONS_KEY (bool, CopyDexFiles) DEX2OAT_OPTIONS_KEY (Unit, AvoidStoringInvocation) DEX2OAT_OPTIONS_KEY (std::string, SwapFile) DEX2OAT_OPTIONS_KEY (int, SwapFileFd) diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h index c6ce951506..303c873349 100644 --- a/dex2oat/linker/image_test.h +++ b/dex2oat/linker/image_test.h @@ -276,7 +276,7 @@ inline void CompilationHelper::Compile(CompilerDriver* driver, &key_value_store, /* verify */ false, // Dex files may be dex-to-dex-ed, don't verify. /* update_input_vdex */ false, - /* copy_dex_files */ CopyOption::kOnlyIfCompressed, + /* extract_dex_files */ true, &cur_opened_dex_files_maps, &cur_opened_dex_files); ASSERT_TRUE(dex_files_ok); diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc index 4dbbc56c56..ee872db558 100644 --- a/dex2oat/linker/oat_writer.cc +++ b/dex2oat/linker/oat_writer.cc @@ -643,7 +643,7 @@ bool OatWriter::WriteAndOpenDexFiles( SafeMap<std::string, std::string>* key_value_store, bool verify, bool update_input_vdex, - CopyOption copy_dex_files, + bool copy_dex_files, /*out*/ std::vector<std::unique_ptr<MemMap>>* opened_dex_files_map, /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files) { CHECK(write_state_ == WriteState::kAddingDexFileSources); @@ -3343,13 +3343,13 @@ bool OatWriter::RecordOatDataOffset(OutputStream* out) { bool OatWriter::WriteDexFiles(OutputStream* out, File* file, bool update_input_vdex, - CopyOption copy_dex_files) { + bool copy_dex_files) { TimingLogger::ScopedTiming split("Write Dex files", timings_); vdex_dex_files_offset_ = vdex_size_; // If extraction is enabled, only do it if not all the dex files are aligned and uncompressed. - if (copy_dex_files == CopyOption::kOnlyIfCompressed) { + if (copy_dex_files) { extract_dex_files_into_vdex_ = false; for (OatDexFile& oat_dex_file : oat_dex_files_) { if (!oat_dex_file.source_.IsZipEntry()) { @@ -3362,10 +3362,7 @@ bool OatWriter::WriteDexFiles(OutputStream* out, break; } } - } else if (copy_dex_files == CopyOption::kAlways) { - extract_dex_files_into_vdex_ = true; } else { - DCHECK(copy_dex_files == CopyOption::kNever); extract_dex_files_into_vdex_ = false; } diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h index 2bc56c68a7..6a7e1e4fbf 100644 --- a/dex2oat/linker/oat_writer.h +++ b/dex2oat/linker/oat_writer.h @@ -24,7 +24,6 @@ #include "base/array_ref.h" #include "base/dchecked_vector.h" -#include "compiler.h" #include "dex/compact_dex_level.h" #include "debug/debug_info.h" #include "linker/relative_patcher.h" // For RelativePatcherTargetProvider. @@ -169,6 +168,7 @@ class OatWriter { // This is generally the case, and should only be false for tests. // If `update_input_vdex` is true, then this method won't actually write the dex files, // and the compiler will just re-use the existing vdex file. + // If `copy_dex_files` is true, copy the input dex files into the vdex file. bool WriteAndOpenDexFiles(File* vdex_file, OutputStream* oat_rodata, InstructionSet instruction_set, @@ -176,7 +176,7 @@ class OatWriter { SafeMap<std::string, std::string>* key_value_store, bool verify, bool update_input_vdex, - CopyOption copy_dex_files, + bool copy_dex_files, /*out*/ std::vector<std::unique_ptr<MemMap>>* opened_dex_files_map, /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files); bool WriteQuickeningInfo(OutputStream* vdex_out); @@ -288,7 +288,7 @@ class OatWriter { bool WriteDexFiles(OutputStream* out, File* file, bool update_input_vdex, - CopyOption copy_dex_files); + bool copy_dex_files); bool WriteDexFile(OutputStream* out, File* file, OatDexFile* oat_dex_file, diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc index 00b9abe69b..6dd8e1988e 100644 --- a/dex2oat/linker/oat_writer_test.cc +++ b/dex2oat/linker/oat_writer_test.cc @@ -198,7 +198,7 @@ class OatTest : public CommonCompilerTest { &key_value_store, verify, /* update_input_vdex */ false, - CopyOption::kOnlyIfCompressed, + compiler_driver_->GetCompilerOptions().GetCompilerFilter(), &opened_dex_files_maps, &opened_dex_files)) { return false; diff --git a/libdexfile/dex/dex_file_loader.cc b/libdexfile/dex/dex_file_loader.cc index 758a2f0599..f0e54eab27 100644 --- a/libdexfile/dex/dex_file_loader.cc +++ b/libdexfile/dex/dex_file_loader.cc @@ -204,12 +204,10 @@ std::string DexFileLoader::GetDexCanonicalLocation(const char* dex_location) { // All of the implementations here should be independent of the runtime. // TODO: implement all the virtual methods. -bool DexFileLoader::GetMultiDexChecksums( - const char* filename ATTRIBUTE_UNUSED, - std::vector<uint32_t>* checksums ATTRIBUTE_UNUSED, - std::string* error_msg, - int zip_fd ATTRIBUTE_UNUSED, - bool* zip_file_only_contains_uncompress_dex ATTRIBUTE_UNUSED) const { +bool DexFileLoader::GetMultiDexChecksums(const char* filename ATTRIBUTE_UNUSED, + std::vector<uint32_t>* checksums ATTRIBUTE_UNUSED, + std::string* error_msg, + int zip_fd ATTRIBUTE_UNUSED) const { *error_msg = "UNIMPLEMENTED"; return false; } diff --git a/libdexfile/dex/dex_file_loader.h b/libdexfile/dex/dex_file_loader.h index 28cdfc13ce..8d1cfaedb1 100644 --- a/libdexfile/dex/dex_file_loader.h +++ b/libdexfile/dex/dex_file_loader.h @@ -108,8 +108,7 @@ class DexFileLoader { virtual bool GetMultiDexChecksums(const char* filename, std::vector<uint32_t>* checksums, std::string* error_msg, - int zip_fd = -1, - bool* zip_file_only_contains_uncompress_dex = nullptr) const; + int zip_fd = -1) const; // Opens .dex file, backed by existing memory virtual std::unique_ptr<const DexFile> Open(const uint8_t* base, diff --git a/runtime/dex/art_dex_file_loader.cc b/runtime/dex/art_dex_file_loader.cc index c456764834..14386a3423 100644 --- a/runtime/dex/art_dex_file_loader.cc +++ b/runtime/dex/art_dex_file_loader.cc @@ -85,8 +85,7 @@ static constexpr OatDexFile* kNoOatDexFile = nullptr; bool ArtDexFileLoader::GetMultiDexChecksums(const char* filename, std::vector<uint32_t>* checksums, std::string* error_msg, - int zip_fd, - bool* zip_file_only_contains_uncompressed_dex) const { + int zip_fd) const { CHECK(checksums != nullptr); uint32_t magic; @@ -120,17 +119,7 @@ bool ArtDexFileLoader::GetMultiDexChecksums(const char* filename, return false; } - if (zip_file_only_contains_uncompressed_dex != nullptr) { - // Start by assuming everything is uncompressed. - *zip_file_only_contains_uncompressed_dex = true; - } - do { - if (zip_file_only_contains_uncompressed_dex != nullptr) { - if (!(zip_entry->IsUncompressed() && zip_entry->IsAlignedToDexHeader())) { - *zip_file_only_contains_uncompressed_dex = false; - } - } checksums->push_back(zip_entry->GetCrc32()); zip_entry_name = GetMultiDexClassesDexName(i++); zip_entry.reset(zip_archive->Find(zip_entry_name.c_str(), error_msg)); diff --git a/runtime/dex/art_dex_file_loader.h b/runtime/dex/art_dex_file_loader.h index 7c7a59b37f..3585381f9b 100644 --- a/runtime/dex/art_dex_file_loader.h +++ b/runtime/dex/art_dex_file_loader.h @@ -50,8 +50,7 @@ class ArtDexFileLoader : public DexFileLoader { bool GetMultiDexChecksums(const char* filename, std::vector<uint32_t>* checksums, std::string* error_msg, - int zip_fd = -1, - bool* only_contains_uncompressed_dex = nullptr) const OVERRIDE; + int zip_fd = -1) const OVERRIDE; // Opens .dex file, backed by existing memory std::unique_ptr<const DexFile> Open(const uint8_t* base, diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index 6bf05b77a8..0170073e29 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -515,18 +515,6 @@ OatFileAssistant::OatStatus OatFileAssistant::GivenOatFileStatus(const OatFile& VLOG(oat) << "Image checksum test skipped for compiler filter " << current_compiler_filter; } - // zip_file_only_contains_uncompressed_dex_ is only set during fetching the dex checksums. - DCHECK(required_dex_checksums_attempted_); - if (only_load_system_executable_ && - !LocationIsOnSystem(file.GetLocation().c_str()) && - file.ContainsDexCode() && - zip_file_only_contains_uncompressed_dex_) { - LOG(ERROR) << "Not loading " - << dex_location_ - << ": oat file has dex code, but APK has uncompressed dex code"; - return kOatDexOutOfDate; - } - if (CompilerFilter::IsAotCompilationEnabled(current_compiler_filter)) { if (!file.IsPic()) { const ImageInfo* image_info = GetImageInfo(); @@ -891,8 +879,7 @@ const std::vector<uint32_t>* OatFileAssistant::GetRequiredDexChecksums() { if (dex_file_loader.GetMultiDexChecksums(dex_location_.c_str(), &cached_required_dex_checksums_, &error_msg, - zip_fd_, - &zip_file_only_contains_uncompressed_dex_)) { + zip_fd_)) { required_dex_checksums_found_ = true; has_original_dex_files_ = true; } else { diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h index 6da49a9c29..a184807b73 100644 --- a/runtime/oat_file_assistant.h +++ b/runtime/oat_file_assistant.h @@ -508,9 +508,6 @@ class OatFileAssistant { // Whether only oat files on /system are loaded executable. const bool only_load_system_executable_ = false; - // Whether the potential zip file only contains uncompressed dex. - // Will be set during GetRequiredDexChecksums. - bool zip_file_only_contains_uncompressed_dex_ = true; // Cached value of the required dex checksums. // This should be accessed only by the GetRequiredDexChecksums() method. diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index c61ecc880b..c7f73d14db 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -334,8 +334,6 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize .IntoKey(M::HiddenApiChecks) .Define("-Xuse-stderr-logger") .IntoKey(M::UseStderrLogger) - .Define("-Xonly-use-system-oat-files") - .IntoKey(M::OnlyUseSystemOatFiles) .Ignore({ "-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa", "-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_", diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 4442fc6a54..2074f1e5f5 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1593,11 +1593,6 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { VLOG(startup) << "Runtime::Init exiting"; - // Set OnlyUseSystemOatFiles only after boot classpath has been set up. - if (runtime_options.Exists(Opt::OnlyUseSystemOatFiles)) { - oat_file_manager_->SetOnlyUseSystemOatFiles(); - } - return true; } diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def index 4121ad69ed..dba648e785 100644 --- a/runtime/runtime_options.def +++ b/runtime/runtime_options.def @@ -152,6 +152,4 @@ RUNTIME_OPTIONS_KEY (bool, SlowDebug, false) RUNTIME_OPTIONS_KEY (unsigned int, GlobalRefAllocStackTraceLimit, 0) // 0 = off RUNTIME_OPTIONS_KEY (Unit, UseStderrLogger) -RUNTIME_OPTIONS_KEY (Unit, OnlyUseSystemOatFiles) - #undef RUNTIME_OPTIONS_KEY diff --git a/test/677-fsi/build b/test/677-fsi/build deleted file mode 100755 index b90b408d9c..0000000000 --- a/test/677-fsi/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -./default-build "$@" --zip-compression-method store --zip-align 4 diff --git a/test/677-fsi/check b/test/677-fsi/check deleted file mode 100644 index 68b4c23ca4..0000000000 --- a/test/677-fsi/check +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2014 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Remove log header. -sed -s 's/^dalvikvm.* E.*\] //' "$2" > "$2.tmp" - -# Remove part of message containing filename. -sed -s 's/^.*: //' "$2.tmp" > "$2.tmp2" - -diff --strip-trailing-cr -q "$1" "$2.tmp2" >/dev/null diff --git a/test/677-fsi/expected.txt b/test/677-fsi/expected.txt deleted file mode 100644 index c7fb8fed77..0000000000 --- a/test/677-fsi/expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -oat file has dex code, but APK has uncompressed dex code -oat file has dex code, but APK has uncompressed dex code -Hello World diff --git a/test/677-fsi/info.txt b/test/677-fsi/info.txt deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/677-fsi/info.txt +++ /dev/null diff --git a/test/677-fsi/run b/test/677-fsi/run deleted file mode 100644 index e9c9292c6b..0000000000 --- a/test/677-fsi/run +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -exec ${RUN} $@ -Xcompiler-option --copy-dex-files=always --runtime-option -Xonly-use-system-oat-files diff --git a/test/677-fsi/src/Main.java b/test/677-fsi/src/Main.java deleted file mode 100644 index 834075f67a..0000000000 --- a/test/677-fsi/src/Main.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class Main { - public static void main(String[] args) { - System.out.println("Hello World"); - } -} diff --git a/test/knownfailures.json b/test/knownfailures.json index dec5cd7591..ddf9098c64 100644 --- a/test/knownfailures.json +++ b/test/knownfailures.json @@ -668,10 +668,5 @@ "env_vars": {"SANITIZE_HOST": "address"}, "bug": "b/73060923", "description": ["ASAN issue"] - }, - { - "tests": "677-fsi", - "variant": "no-dex2oat | no-image | no-prebuild | relocate-npatchoat", - "description": ["Test requires a successful dex2oat invocation"] } ] |