From e48fd0b4780efadc6b3433fe7a56aa5be2a84325 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Mon, 20 May 2019 10:04:44 -0700 Subject: Add verifier fallback for JVMTI Get/SetLocalVariable The JVMTI Get/SetLocalVariable functions used to rely entirely on the Dex DebugInfo to determine the types of each of the registers. This could lead to problems since, to prevent possible stack corruption, we would not allow stack modification if the data was not present. In order to remove this restriction we will instead make use of the method verifier to ensure the modification is sensible when the DebugInfo is not present. Since reconstructing this information using the verifier is quite slow (compared to reading it from a table) we will only do this when the table is missing. Since the verifier lacks some of the information available when creating the DebugLocalInfo table some semantics will change depending on if the table is present or not. - When the DebugLocalInfo table is not present we cannot always distinguish between floats, ints, and other single-register primitive types. For simplicity all single-register primitive types can be modified and read by both the Float and Int versions of the local variable functions. - Similarly we cannot always distinguish between long and double variables. - Reference types are checked against what the verifier thinks they need to be according to type unification. This might be more or less specific than the types recorded in the functions source code. - Constant int/float '0' values and 'null' cannot always be differentiated by the verifier. Therefore, one may not always be able to modify some null or constant 0 registers. Test: ./test.py --host Bug: 131711256 Change-Id: I1c9d857ccdec752bfd4ebad76cc9ad96e143866c --- .../src/Main.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/1966-get-set-local-objects-no-table/src/Main.java (limited to 'test/1966-get-set-local-objects-no-table/src/Main.java') diff --git a/test/1966-get-set-local-objects-no-table/src/Main.java b/test/1966-get-set-local-objects-no-table/src/Main.java new file mode 100644 index 0000000000..198f319421 --- /dev/null +++ b/test/1966-get-set-local-objects-no-table/src/Main.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 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) throws Exception { + art.Test1966.run(); + } +} -- cgit v1.2.3-59-g8ed1b