From 4d7b689fe667a65138eceb311767a3d624fb0e4b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 16 Jan 2020 17:06:35 +0000 Subject: Fix Transaction constraint validation... ... for boot image extensions. Add WriteConstraint checks to APUT instructions and add necessary WriteConstraint and WriteValueConstraint checks to UnstartedRuntime. For strict transactions (app compilation), prevent writing to boot image objects. However, more work is required for this use case as the UnstartedRuntime needs a review for missing ReadConstraint checks and the WriteValueConstraint may need to be more restrictive. While the transaction_test is improved to test Transaction constraints more thoroughly, no regression tests are provided for the previously missing checks. Such tests are difficult to write as they would require compilation of a custom boot image. Test: Manual; include java.lang.Locale[] in primary boot image by patching CompilerDriver::LoadImageClasses(), + if (GetCompilerOptions().IsBootImage()) { + image_classes->insert("[Ljava/util/Locale;"); + } , and build. This previously aborted in ImageWriter: Image object without assigned bin slot: \ java.util.concurrent.ConcurrentHashMap$Node Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 119800099 Bug: 147596904 Change-Id: Ibfe1b24b10dbd982b4e4ae4d98289e587a842812 --- runtime/interpreter/interpreter_switch_impl-inl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime/interpreter/interpreter_switch_impl-inl.h') diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h index 989f99740e..863612fae2 100644 --- a/runtime/interpreter/interpreter_switch_impl-inl.h +++ b/runtime/interpreter/interpreter_switch_impl-inl.h @@ -343,6 +343,9 @@ class InstructionHandler { if (UNLIKELY(!array->CheckIsValidIndex(index))) { return false; // Pending exception. } else { + if (transaction_active && !CheckWriteConstraint(self, array)) { + return false; + } array->template SetWithoutChecks(index, value); } return true; @@ -974,7 +977,8 @@ class InstructionHandler { ObjPtr val = GetVRegReference(A()); ObjPtr> array = a->AsObjectArray(); if (array->CheckIsValidIndex(index) && array->CheckAssignable(val)) { - if (transaction_active && !CheckWriteValueConstraint(self, val)) { + if (transaction_active && + (!CheckWriteConstraint(self, array) || !CheckWriteValueConstraint(self, val))) { return false; } array->SetWithoutChecks(index, val); -- cgit v1.2.3-59-g8ed1b