Skip to content

Commit

Permalink
Patch cmake for CVE-2023-28320 (#9946)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhichun Wan <[email protected]>
Co-authored-by: jslobodzian <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent 6a8cead commit 45d3f41
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
78 changes: 78 additions & 0 deletions SPECS/cmake/CVE-2023-28320.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
From def1a172f3a5ac13c3cd5687d2a352262b02e358 Mon Sep 17 00:00:00 2001
From: Zhichun Wan <[email protected]>
Date: Fri, 26 Jul 2024 22:30:10 +0000
Subject: [PATCH] patches

---
Utilities/cmcurl/lib/hostip.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/Utilities/cmcurl/lib/hostip.c b/Utilities/cmcurl/lib/hostip.c
index e0e3cfc2..a763ad84 100644
--- a/Utilities/cmcurl/lib/hostip.c
+++ b/Utilities/cmcurl/lib/hostip.c
@@ -72,12 +72,19 @@
#include <SystemConfiguration/SCDynamicStoreCopySpecific.h>
#endif

-#if defined(CURLRES_SYNCH) && \
- defined(HAVE_ALARM) && defined(SIGALRM) && defined(HAVE_SIGSETJMP)
+#if defined(CURLRES_SYNCH) && \
+ defined(HAVE_ALARM) && \
+ defined(SIGALRM) && \
+ defined(HAVE_SIGSETJMP) && \
+ defined(GLOBAL_INIT_IS_THREADSAFE)
/* alarm-based timeouts can only be used with all the dependencies satisfied */
#define USE_ALARM_TIMEOUT
#endif

+#ifdef USE_ALARM_TIMEOUT
+#include "easy_lock.h"
+#endif
+
#define MAX_HOSTCACHE_LEN (255 + 7) /* max FQDN + colon + port number + zero */

/*
@@ -249,11 +256,12 @@ void Curl_hostcache_prune(struct Curl_easy *data)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}

-#ifdef HAVE_SIGSETJMP
+#ifdef USE_ALARM_TIMEOUT
/* Beware this is a global and unique instance. This is used to store the
return address that we can jump back to from inside a signal handler. This
is not thread-safe stuff. */
sigjmp_buf curl_jmpenv;
+curl_simple_lock curl_jmpenv_lock;
#endif

/* lookup address, returns entry if found and not stale */
@@ -640,7 +648,6 @@ enum resolve_t Curl_resolv(struct Curl_easy *data,
static
void alarmfunc(int sig)
{
- /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */
(void)sig;
siglongjmp(curl_jmpenv, 1);
}
@@ -720,6 +727,8 @@ enum resolve_t Curl_resolv_timeout(struct Curl_easy *data,
This should be the last thing we do before calling Curl_resolv(),
as otherwise we'd have to worry about variables that get modified
before we invoke Curl_resolv() (and thus use "volatile"). */
+ curl_simple_lock_lock(&curl_jmpenv_lock);
+
if(sigsetjmp(curl_jmpenv, 1)) {
/* this is coming from a siglongjmp() after an alarm signal */
failf(data, "name lookup timed out");
@@ -788,6 +797,8 @@ clean_up:
#endif
#endif /* HAVE_SIGACTION */

+ curl_simple_lock_unlock(&curl_jmpenv_lock);
+
/* switch back the alarm() to either zero or to what it was before minus
the time we spent until now! */
if(prev_alarm) {
--
2.39.4

6 changes: 5 additions & 1 deletion SPECS/cmake/cmake.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Cmake
Name: cmake
Version: 3.21.4
Release: 10%{?dist}
Release: 11%{?dist}
License: BSD AND LGPLv2+
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -20,6 +20,7 @@ Patch5: CVE-2023-35945.patch
Patch6: CVE-2023-38545.patch
Patch7: CVE-2023-38546.patch
Patch8: cve-2023-44487.patch
Patch9: CVE-2023-28320.patch
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: curl
Expand Down Expand Up @@ -85,6 +86,9 @@ bin/ctest --force-new-ctest-process --rerun-failed --output-on-failure
%{_prefix}/doc/%{name}-*/*

%changelog
* Fri Jul 26 2024 Zhichun Wan <[email protected]> - 3.21.4-11
- Patch CVE-2023-28320.patch

* Thu Oct 19 2023 Dan Streetman <[email protected]> - 3.21.4-10
- Patch vendored nghttp2 for CVE-2023-44487

Expand Down
4 changes: 2 additions & 2 deletions toolkit/resources/manifests/package/toolchain_aarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ check-debuginfo-0.15.2-1.cm2.aarch64.rpm
chkconfig-1.20-4.cm2.aarch64.rpm
chkconfig-debuginfo-1.20-4.cm2.aarch64.rpm
chkconfig-lang-1.20-4.cm2.aarch64.rpm
cmake-3.21.4-10.cm2.aarch64.rpm
cmake-debuginfo-3.21.4-10.cm2.aarch64.rpm
cmake-3.21.4-11.cm2.aarch64.rpm
cmake-debuginfo-3.21.4-11.cm2.aarch64.rpm
coreutils-8.32-7.cm2.aarch64.rpm
coreutils-debuginfo-8.32-7.cm2.aarch64.rpm
coreutils-lang-8.32-7.cm2.aarch64.rpm
Expand Down
4 changes: 2 additions & 2 deletions toolkit/resources/manifests/package/toolchain_x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ check-debuginfo-0.15.2-1.cm2.x86_64.rpm
chkconfig-1.20-4.cm2.x86_64.rpm
chkconfig-debuginfo-1.20-4.cm2.x86_64.rpm
chkconfig-lang-1.20-4.cm2.x86_64.rpm
cmake-3.21.4-10.cm2.x86_64.rpm
cmake-debuginfo-3.21.4-10.cm2.x86_64.rpm
cmake-3.21.4-11.cm2.x86_64.rpm
cmake-debuginfo-3.21.4-11.cm2.x86_64.rpm
coreutils-8.32-7.cm2.x86_64.rpm
coreutils-debuginfo-8.32-7.cm2.x86_64.rpm
coreutils-lang-8.32-7.cm2.x86_64.rpm
Expand Down

0 comments on commit 45d3f41

Please sign in to comment.