diff --git a/0013-Backport-Bitcode-Add-some-missing-GetTypeByID-failure-checks.patch b/0013-Backport-Bitcode-Add-some-missing-GetTypeByID-failure-checks.patch new file mode 100644 index 0000000000000000000000000000000000000000..0d365dbb2013e578aa6441e0656b00f4d626c0a1 --- /dev/null +++ b/0013-Backport-Bitcode-Add-some-missing-GetTypeByID-failure-checks.patch @@ -0,0 +1,37 @@ +From 58f4b115f97435efa1df1baa3247791a13444c00 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Tue, 26 Sep 2023 16:51:40 +0200 +Subject: [PATCH 1/3] [Bitcode] Add some missing GetTypeByID failure checks + +Print an error instead of crashing. + +Fixes https://github.com/llvm/llvm-project/issues/67388. +--- + llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +index 0a9a80688a41..2f024899b451 100644 +--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp ++++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +@@ -1315,7 +1315,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( + + unsigned TyID = Record[0]; + Type *Ty = Callbacks.GetTypeByID(TyID); +- if (Ty->isMetadataTy() || Ty->isVoidTy()) { ++ if (!Ty || Ty->isMetadataTy() || Ty->isVoidTy()) { + dropRecord(); + break; + } +@@ -1366,7 +1366,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( + + unsigned TyID = Record[0]; + Type *Ty = Callbacks.GetTypeByID(TyID); +- if (Ty->isMetadataTy() || Ty->isVoidTy()) ++ if (!Ty || Ty->isMetadataTy() || Ty->isVoidTy()) + return error("Invalid record"); + + Value *V = ValueList.getValueFwdRef(Record[1], Ty, TyID, +-- +2.33.0 + diff --git a/llvm.spec b/llvm.spec index 12d277f6f3c32a1eddd17ccc7c02f98eefc60592..41ad3608ea9a6fa52679608312c75ce6b6d94ba0 100644 --- a/llvm.spec +++ b/llvm.spec @@ -37,7 +37,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 4 +Release: 5 Summary: The Low Level Virtual Machine License: NCSA @@ -60,6 +60,7 @@ Patch10: 0010-Backport-Mips-MC-AttemptToFoldSymbolOffsetDifference-revert-isMic Patch11: 0011-Backport-LoongArch-Add-the-support-for-vector-in-llvm17.patch Patch12: 0012-Backport-LoongArch-improve-the-support-for-compiler-rt-and-bugfix.patch +Patch13: 0013-Backport-Bitcode-Add-some-missing-GetTypeByID-failure-checks.patch BuildRequires: binutils-devel BuildRequires: cmake @@ -342,6 +343,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build %{install_includedir}/llvm-gmock %changelog +* Tue Apr 09 2024 liyunfei - 17.0.6-5 +- Backport patch to fix CVE-2023-46049 + * Wed Apr 03 2024 zhanglimin - 17.0.6-4 - Improve the support for compiler-rt and fix some bugs on LoongArch