diff mbox series

[meta-java,dunfell,2/3] openjdk: Fix CVE-2022-21540 for openjdk

Message ID 20220828161515.14337-1-virendra.thakur@kpit.com
State New
Headers show
Series None | expand

Commit Message

Virendra Kumar Thakur Aug. 28, 2022, 4:15 p.m. UTC
From: Virendra Thakur <virendrak@kpit.com>

Add patch to fix CVE-2022-21540

Reference:
https://github.com/openjdk/jdk/commit/84b4e9bb415de65d8de83925fbf7010ed1650064

https://launchpadlibrarian.net/614309983/openjdk-8_8u342~b06-1_8u342-b07-1.diff.gz

Signed-off-by: Virendra Thakur <virendrak@kpit.com>
---
 .../openjdk/openjdk-8-release-common.inc      |  1 +
 .../patches-openjdk-8/CVE-2022-21540.patch    | 54 +++++++++++++++++++
 2 files changed, 55 insertions(+)
 create mode 100644 recipes-core/openjdk/patches-openjdk-8/CVE-2022-21540.patch

--
2.17.1

This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
diff mbox series

Patch

diff --git a/recipes-core/openjdk/openjdk-8-release-common.inc b/recipes-core/openjdk/openjdk-8-release-common.inc
index cebbc0b..b50bddc 100644
--- a/recipes-core/openjdk/openjdk-8-release-common.inc
+++ b/recipes-core/openjdk/openjdk-8-release-common.inc
@@ -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 \
diff --git a/recipes-core/openjdk/patches-openjdk-8/CVE-2022-21540.patch b/recipes-core/openjdk/patches-openjdk-8/CVE-2022-21540.patch
new file mode 100644
index 0000000..c311e5c
--- /dev/null
+++ b/recipes-core/openjdk/patches-openjdk-8/CVE-2022-21540.patch
@@ -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);