diff options
author | 2019-05-20 10:04:44 -0700 | |
---|---|---|
committer | 2019-05-22 00:29:38 +0000 | |
commit | e48fd0b4780efadc6b3433fe7a56aa5be2a84325 (patch) | |
tree | 5056001e02d8c4494b643c8d53fd32621e127c1c /runtime/verifier/method_verifier.h | |
parent | abdb4592fa28d6e75f1160f01cde58ad7c3fef37 (diff) |
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
Diffstat (limited to 'runtime/verifier/method_verifier.h')
-rw-r--r-- | runtime/verifier/method_verifier.h | 10 |
1 files changed, 10 insertions, 0 deletions
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<mirror::DexCache> dex_cache, + Handle<mirror::ClassLoader> class_loader) + REQUIRES_SHARED(Locks::mutator_lock_); + const DexFile& GetDexFile() const { DCHECK(dex_file_ != nullptr); return *dex_file_; |