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 --- runtime/verifier/method_verifier.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'runtime/verifier/method_verifier.h') diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index 0af09c32c7..bd320ce2a2 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -118,6 +118,16 @@ class MethodVerifier { uint32_t api_level) REQUIRES_SHARED(Locks::mutator_lock_); + // Calculates the verification information for every instruction of the given method. The given + // dex-cache and class-loader will be used for lookups. No classes will be loaded. If verification + // fails hard nullptr will be returned. This should only be used if one needs to examine what the + // verifier believes about the registers of a given method. + static MethodVerifier* CalculateVerificationInfo(Thread* self, + ArtMethod* method, + Handle dex_cache, + Handle class_loader) + REQUIRES_SHARED(Locks::mutator_lock_); + const DexFile& GetDexFile() const { DCHECK(dex_file_ != nullptr); return *dex_file_; -- cgit v1.2.3-59-g8ed1b