@@ -22,6 +22,7 @@ PATCHES_URI = "\
file://2008-jdk-no-unused-deps.patch \
file://2009-jdk-make-use-gcc-instead-of-ld-for-genSocketOptionRe.patch \
file://CVE-2022-34169.patch \
+ file://CVE-2022-21540.patch \
"
HOTSPOT_UB_PATCH = "\
file://1001-hotspot-fix-crash-on-JNI_CreateJavaVM.patch \
new file mode 100644
@@ -0,0 +1,54 @@
+From 84b4e9bb415de65d8de83925fbf7010ed1650064 Mon Sep 17 00:00:00 2001
+From: Tobias Hartmann <thartmann@openjdk.org>
+Date: Fri, 18 Mar 2022 10:08:18 +0000
+Subject: [PATCH] 8281859: Improve class compilation
+
+Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
+Reviewed-by: chagedorn
+Signed-off-by: Virendra Thakur <virendra.thakur@kpit.com>
+
+CVE: CVE-2022-21540
+
+Upstream-Status: Backport [https://launchpadlibrarian.net/614309983/openjdk-8_8u342~b06-1_8u342-b07-1.diff.gz]
+---
+Index: openjdk/hotspot/src/share/vm/ci/ciEnv.cpp
+===================================================================
+--- a/hotspot/src/share/vm/ci/ciEnv.cpp
++++ b/hotspot/src/share/vm/ci/ciEnv.cpp
+@@ -587,7 +587,6 @@ ciKlass* ciEnv::get_klass_by_index(const
+ ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
+ int pool_index, int cache_index,
+ ciInstanceKlass* accessor) {
+- bool ignore_will_link;
+ EXCEPTION_CONTEXT;
+ int index = pool_index;
+ if (cache_index >= 0) {
+@@ -634,8 +633,8 @@ ciConstant ciEnv::get_constant_by_index_
+ return ciConstant(T_OBJECT, constant);
+ }
+ } else if (tag.is_klass() || tag.is_unresolved_klass()) {
+- // 4881222: allow ldc to take a class type
+- ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor);
++ bool will_link;
++ ciKlass* klass = get_klass_by_index_impl(cpool, index, will_link, accessor);
+ if (HAS_PENDING_EXCEPTION) {
+ CLEAR_PENDING_EXCEPTION;
+ record_out_of_memory_failure();
+@@ -643,7 +642,8 @@ ciConstant ciEnv::get_constant_by_index_
+ }
+ assert (klass->is_instance_klass() || klass->is_array_klass(),
+ "must be an instance or array klass ");
+- return ciConstant(T_OBJECT, klass->java_mirror());
++ ciInstance* mirror = (will_link ? klass->java_mirror() : get_unloaded_klass_mirror(klass));
++ return ciConstant(T_OBJECT, mirror);
+ } else if (tag.is_method_type()) {
+ // must execute Java code to link this CP entry into cache[i].f1
+ ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
+@@ -651,6 +651,7 @@ ciConstant ciEnv::get_constant_by_index_
+ return ciConstant(T_OBJECT, ciobj);
+ } else if (tag.is_method_handle()) {
+ // must execute Java code to link this CP entry into cache[i].f1
++ bool ignore_will_link;
+ int ref_kind = cpool->method_handle_ref_kind_at(index);
+ int callee_index = cpool->method_handle_klass_index_at(index);
+ ciKlass* callee = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor);