summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2018-09-04 09:26:03 -0700
committer Andreas Gampe <agampe@google.com> 2018-09-04 09:31:03 -0700
commitdc39d32cc0c72af00b58c58077fb2cad6774df03 (patch)
treeae3cce77bb8540717273fca4aad880e6b5a238bc
parentff71e663a08b4218fc9d08f8e65ad7da84a4ab99 (diff)
Revert^2: "ART: Restrict some checks in the verifier to P+"
Reinstate old behavior for apps targeting earlier releases. This reverts commit 5ff2596da427351308992a1677348e460a398591. Bug: 111969862 Bug: 113863780 Test: m test-art-host Test: cts-tradefed run commandAndExit cts --m vm-tests-tf Change-Id: I4fd967271cf43e21af34739a08907a1a7953539a
-rw-r--r--runtime/verifier/method_verifier.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 2064fc427e..5fce892ee6 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3675,9 +3675,11 @@ const RegType& MethodVerifier::ResolveClass(dex::TypeIndex class_idx) {
// the access-checks interpreter. If result is primitive, skip the access check.
//
// Note: we do this for unresolved classes to trigger re-verification at runtime.
- if (C == CheckAccess::kYes && result->IsNonZeroReferenceTypes()) {
+ if (C == CheckAccess::kYes &&
+ result->IsNonZeroReferenceTypes() &&
+ (api_level_ >= 28u || !result->IsUnresolvedTypes())) {
const RegType& referrer = GetDeclaringClass();
- if (!referrer.CanAccess(*result)) {
+ if ((api_level_ >= 28u || !referrer.IsUnresolvedTypes()) && !referrer.CanAccess(*result)) {
Fail(VERIFY_ERROR_ACCESS_CLASS) << "(possibly) illegal class access: '"
<< referrer << "' -> '" << *result << "'";
}
@@ -4560,7 +4562,7 @@ ArtField* MethodVerifier::GetStaticField(int field_idx) {
}
if (klass_type.IsUnresolvedTypes()) {
// Accessibility checks depend on resolved fields.
- DCHECK(klass_type.Equals(GetDeclaringClass()) || !failures_.empty());
+ DCHECK(klass_type.Equals(GetDeclaringClass()) || !failures_.empty() || api_level_ < 28u);
return nullptr; // Can't resolve Class so no more to do here, will do checking at runtime.
}
@@ -4601,7 +4603,7 @@ ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_id
}
if (klass_type.IsUnresolvedTypes()) {
// Accessibility checks depend on resolved fields.
- DCHECK(klass_type.Equals(GetDeclaringClass()) || !failures_.empty());
+ DCHECK(klass_type.Equals(GetDeclaringClass()) || !failures_.empty() || api_level_ < 28u);
return nullptr; // Can't resolve Class so no more to do here
}
@@ -4737,7 +4739,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType&
DCHECK(!can_load_classes_ || self_->IsExceptionPending());
self_->ClearException();
}
- } else {
+ } else if (api_level_ >= 28u) {
// If we don't have the field (it seems we failed resolution) and this is a PUT, we need to
// redo verification at runtime as the field may be final, unless the field id shows it's in
// the same class.