RFR: 8284877: Check type compatibility before looking up method from receiver's vtable [v3]

Yi Yang yyang at openjdk.org
Fri Jun 16 02:26:23 UTC 2023


> Hi, can I have a review for this enhancement? This patch adds type compatibility check before method lookup for robustness. In some internal cases, serialization framework may improperly generate an object of wrong type, which leads JVM randomly crashes during method resolution.
> 
> For example:
> 
> invokevirtual selected method: receiver-class:java.util.ArrayList, resolved-class:com.taobao.forest.domain.util.LongMapSupportArrayList, resolved_method:com.taobao.forest.domain.util.LongMapSupportArrayList.toMap()Ljava/util/Map;, selected_method:0x458, vtable_index:56#
> 
> The real type of receiver is ArrayList, while the resolved method is LongMapSupportArrayList.toMap. VM attempts to select method as if looking up from receiver's vtable via vtable index of resolved method(i.e. attempts to lookup `toMap()` from 
>  ArrayList), an invalid method or incorrect method would be selected, thus causing some strange crashes.
> 
> I think it's reasonable to add a type compatibility check before method lookup. If such an incompatible call is found, JVM could throw an exception instead.

Yi Yang has updated the pull request incrementally with one additional commit since the last revision:

   additional type check when -Xcheck:jni

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/8241/files
  - new: https://git.openjdk.org/jdk/pull/8241/files/8acc1b7f..fd56bf08

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=8241&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=8241&range=01-02

  Stats: 23 lines in 2 files changed: 3 ins; 0 del; 20 mod
  Patch: https://git.openjdk.org/jdk/pull/8241.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/8241/head:pull/8241

PR: https://git.openjdk.org/jdk/pull/8241


More information about the hotspot-dev mailing list