curl: fix CVE-2023-28320 siglongjmp race condition may lead to crash
PATCH 1/1 curl: fix CVE-2023-28320 siglongjmp race condition may lead to crash
Introduced by: https://github.com/curl/curl/commit/3c49b405de4fbf1fd7127f91908261268640e54f (curl-7_9_8) Fixed by: https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2 (curl-8_1_0)
Follow-up: https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3 (curl-8_1_0)
https://curl.se/docs/CVE-2023-28320.html
--- .../curl/curl/CVE-2023-28320-fol1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320-pre1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320.patch | 86 ++++++++ meta/recipes-support/curl/curl_7.69.1.bb | 2 + 4 files changed, 482 insertions(+) create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320.patch
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +197 -0
@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H ++/*************************************************************************** ++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++ ***************************************************************************/ ++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MS define */ ++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies in its ++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */ + + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* 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; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr, + #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +197 -0
197 lines not on this page · raw message
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +86 -0
86 lines not on this page · raw message
meta/recipes-support/curl/curl_7.69.1.bb +2 -0
@@ -50,6 +50,8 @@ SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ file://CVE-2023-27535-pre1.patch \ file://CVE-2023-27535.patch \ file://CVE-2023-27536.patch \ + file://CVE-2023-28320.patch \ + file://CVE-2023-28320-fol1.patch \ " SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42"
Signature · 1 line
2.25.1
Quoted 520 lines · vkumbhar
Introduced by: https://github.com/curl/curl/commit/3c49b405de4fbf1fd7127f91908261268640e54f (curl-7_9_8) Fixed by: https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2 (curl-8_1_0)
Follow-up: https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3 (curl-8_1_0)
https://curl.se/docs/CVE-2023-28320.htmlSigned-off-by Vivek Kumbhar <[email protected]>--- .../curl/curl/CVE-2023-28320-fol1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320-pre1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320.patch | 86 ++++++++ meta/recipes-support/curl/curl_7.69.1.bb | 2 + 4 files changed, 482 insertions(+) create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320.patchmeta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +197
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H ++/*************************************************************************** ++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++ ***************************************************************************/ ++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MS define */ ++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies in its ++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */ + + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* 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; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr, + #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +197
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H ++/*************************************************************************** ++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++ ***************************************************************************/ ++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MS define */ ++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies in its ++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */ + + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* 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; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr, + #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +86
-0@@ -0,0 +1,86 @@ +From 13718030ad4b3209a7583b4f27f683cd3a6fa5f2 Mon Sep 17 00:00:00 2001 +From: Harry Sintonen <[email protected]> +Date: Tue, 25 Apr 2023 09:22:26 +0200 +Subject: [PATCH] hostip: add locks around use of global buffer for alarm() + +When building with the sync name resolver and timeout ability we now +require thread-safety to be present to enable it. + +Closes #11030 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/hostip.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/lib/hostip.c b/lib/hostip.c +index f5bb634..5231a74 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,12 +68,19 @@ + #include "curl_memory.h" + #include "memdebug.h" + +-#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 */ + + /* +@@ -248,11 +255,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 */ +@@ -614,7 +622,6 @@ enum resolve_t Curl_resolv(struct connectdata *conn, + static + RETSIGTYPE alarmfunc(int sig) + { +- /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */ + (void)sig; + siglongjmp(curl_jmpenv, 1); + } +@@ -695,6 +702,8 @@ enum resolve_t Curl_resolv_timeout(struct connectdata *conn, + 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"); +@@ -763,6 +772,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.25.1 +meta/recipes-support/curl/curl_7.69.1.bb +0
-0
meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ · line 52
Quoted 3 lines
meta/recipes-support/curl/curl_7.69.1.bb +0
-0@@ -50,6 +50,8 @@ SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ file://CVE-2023-27535-pre1.patch \ file://CVE-2023-27535.patch \ file://CVE-2023-27536.patch \
Shouldn't you be adding CVE-2023-28320-pre1.patch here?
Steve
Quoted 17 lines
meta/recipes-support/curl/curl_7.69.1.bb +2
-1+ file://CVE-2023-28320.patch \ + file://CVE-2023-28320-fol1.patch \ " SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42" --2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#184058): https://lists.openembedded.org/g/openembedded-core/message/184058
Mute This Topic: https://lists.openembedded.org/mt/100053064/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
As it is a followup patch I have added it as fol1.
If you want this as pre1, I will send v2 again.
Kind regards,
Vivek
Quoted 596 lines · Steve Sakoman
Quoted 2 lines · vkumbhar
Introduced by:
https://github.com/curl/curl/commit/3c49b405de4fbf1fd7127f91908261268640e54f
(curl-7_9_8)Quoted 1 line
Fixed by:
https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2
(curl-8_1_0)Quoted 1 line
Follow-up:
https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
(curl-8_1_0)Quoted 10 lines
https://curl.se/docs/CVE-2023-28320.html
Signed-off-by Vivek Kumbhar <[email protected]>--- .../curl/curl/CVE-2023-28320-fol1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320-pre1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320.patch | 86 ++++++++ meta/recipes-support/curl/curl_7.69.1.bb | 2 + 4 files changed, 482 insertions(+) create mode 100644
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patchQuoted 1 line
create mode 100644
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patchReview
Quoted 3 lines
create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320.patch(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patchQuoted 10 lines
new file mode 100644
index 0000000000..eaa6fdc327meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +5
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFEmeta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 15
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +10
-0+ +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
]Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +7
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-)meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 32
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +10
-0+ create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H++/***************************************************************************
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 13 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +13
-0++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/orsell
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTYOF ANY
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 56
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +5
-0++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++***************************************************************************/
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 12 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +12
-0++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MSdefine */
Quoted 20 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +20
-0++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +10
-0++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies inits
Quoted 54 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +54
-0++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +10
-0+ defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0+ + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* Beware this is a global and unique instance. This is used to storethe
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 165
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 13 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +13
-0+ is not thread-safe stuff. */ +-sigjmp_buf curl_jmpenv; +-curl_simple_lock curl_jmpenv_lock; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data,
Curl_addrinfo*addr,Review
Quoted 19 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +18
-0+ #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patchQuoted 10 lines
new file mode 100644
index 0000000000..eaa6fdc327meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +5
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFEmeta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 15
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +10
-0+ +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
]Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +7
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-)meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 32
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +10
-0+ create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H++/***************************************************************************
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 45
Quoted 13 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +13
-0++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/orsell
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 49
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTYOF ANY
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 54
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +5
-0++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++***************************************************************************/
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 66
Quoted 12 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +12
-0++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MSdefine */
Quoted 20 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +20
-0++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 96
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +10
-0++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies inits
Quoted 54 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +54
-0++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 160
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +10
-0+ defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 164
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0+ + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* Beware this is a global and unique instance. This is used to storethe
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 165
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 178
Quoted 13 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +13
-0+ is not thread-safe stuff. */ +-sigjmp_buf curl_jmpenv; +-curl_simple_lock curl_jmpenv_lock; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data,
Curl_addrinfo*addr,Review
Quoted 19 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +18
-0+ #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320.patchmeta/recipes-support/curl/curl/CVE-2023-28320.patch line 4
Quoted 9 lines
new file mode 100644
index 0000000000..0c9b67440ameta/recipes-support/curl/curl/CVE-2023-28320.patch new file +4
-0@@ -0,0 +1,86 @@ +From 13718030ad4b3209a7583b4f27f683cd3a6fa5f2 Mon Sep 17 00:00:00 2001 +From: Harry Sintonen <[email protected]> +Date: Tue, 25 Apr 2023 09:22:26 +0200 +Subject: [PATCH] hostip: add locks around use of global buffer for
alarm()meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 7 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +7
-0+ +When building with the sync name resolver and timeout ability we now +require thread-safety to be present to enable it. + +Closes #11030 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2
]Quoted 12 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +12
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/hostip.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/lib/hostip.c b/lib/hostip.c +index f5bb634..5231a74 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,12 +68,19 @@ + #include "curl_memory.h"meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +10
-0+ #include "memdebug.h" + +-#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 dependenciessatisfied */
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +8
-0+ #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 */
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 9 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +9
-0+ + /* +@@ -248,11 +255,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 storethe
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 51
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 11 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +11
-0+ 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 */ +@@ -614,7 +622,6 @@ enum resolve_t Curl_resolv(struct connectdata *conn, + static + RETSIGTYPE alarmfunc(int sig) + { +- /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe)*/
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +4
-0+ (void)sig; + siglongjmp(curl_jmpenv, 1); + } +@@ -695,6 +702,8 @@ enum resolve_t Curl_resolv_timeout(structconnectdata *conn,
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +5
-0+ 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); ++meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 10 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +10
-0+ if(sigsetjmp(curl_jmpenv, 1)) { + /* this is coming from a siglongjmp() after an alarm signal */ + failf(data, "name lookup timed out"); +@@ -763,6 +772,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 beforeminus
Review
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +5
-0+ the time we spent until now! */ + if(prev_alarm) { +-- +2.25.1 +(quoted diff) +0
-0b/meta/recipes-support/curl/curl_7.69.1.bb
meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "
Quoted 4 lines
index
13ec117099..ce81df0f05100644meta/recipes-support/curl/curl_7.69.1.bb +0
-0@@ -50,6 +50,8 @@ SRC_URI = "meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ · line 52
Quoted 3 lines
meta/recipes-support/curl/curl_7.69.1.bb +0
-0file://CVE-2023-27535-pre1.patch \ file://CVE-2023-27535.patch \ file://CVE-2023-27536.patch \Shouldn't you be adding CVE-2023-28320-pre1.patch here?
Steve
Quoted 9 lines
meta/recipes-support/curl/curl_7.69.1.bb +2
-1+ file://CVE-2023-28320.patch \ + file://CVE-2023-28320-fol1.patch \ " SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42" --2.25.1
Quoted 3 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#184058):https://lists.openembedded.org/g/openembedded-core/message/184058
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/100053064/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 4 lines · Vivek Kumbhar
As it is a followup patch I have added it as fol1.
If you want this as pre1, I will send v2 again.
What is confusing me is that this patch adds three files (CVE-2023-28320-fol1.patch, CVE-2023-28320-pre1.patch, CVE-2023-28320.patch) but then only adds two of them to SRC_URI.
So you should either drop adding CVE-2023-28320-pre1.patch, or add it to SRC_URI.
Make sense?
Steve
Quoted 548 lines · Steve Sakoman
Quoted 547 lines · vkumbhar
Quoted 520 lines
Introduced by: https://github.com/curl/curl/commit/3c49b405de4fbf1fd7127f91908261268640e54f (curl-7_9_8) Fixed by: https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2 (curl-8_1_0)
Follow-up: https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3 (curl-8_1_0)
https://curl.se/docs/CVE-2023-28320.htmlSigned-off-by Vivek Kumbhar <[email protected]>--- .../curl/curl/CVE-2023-28320-fol1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320-pre1.patch | 197 ++++++++++++++++++ .../curl/curl/CVE-2023-28320.patch | 86 ++++++++ meta/recipes-support/curl/curl_7.69.1.bb | 2 + 4 files changed, 482 insertions(+) create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch create mode 100644 meta/recipes-support/curl/curl/CVE-2023-28320.patchmeta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +197
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H ++/*************************************************************************** ++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++ ***************************************************************************/ ++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MS define */ ++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies in its ++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */ + + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* 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; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr, + #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +197
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined. + +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ + lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.h +new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H ++/*************************************************************************** ++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____| ++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++ ***************************************************************************/ ++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFE ++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MS define */ ++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0 ++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* lies in its ++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@ + #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 */ + + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* 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; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock; + #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr, + #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. 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. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers to use. + */ +-- +2.25.1 +meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +86
-0@@ -0,0 +1,86 @@ +From 13718030ad4b3209a7583b4f27f683cd3a6fa5f2 Mon Sep 17 00:00:00 2001 +From: Harry Sintonen <[email protected]> +Date: Tue, 25 Apr 2023 09:22:26 +0200 +Subject: [PATCH] hostip: add locks around use of global buffer for alarm() + +When building with the sync name resolver and timeout ability we now +require thread-safety to be present to enable it. + +Closes #11030 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2] +CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/hostip.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/lib/hostip.c b/lib/hostip.c +index f5bb634..5231a74 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,12 +68,19 @@ + #include "curl_memory.h" + #include "memdebug.h" + +-#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 */ + + /* +@@ -248,11 +255,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 */ +@@ -614,7 +622,6 @@ enum resolve_t Curl_resolv(struct connectdata *conn, + static + RETSIGTYPE alarmfunc(int sig) + { +- /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */ + (void)sig; + siglongjmp(curl_jmpenv, 1); + } +@@ -695,6 +702,8 @@ enum resolve_t Curl_resolv_timeout(struct connectdata *conn, + 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"); +@@ -763,6 +772,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.25.1 +meta/recipes-support/curl/curl_7.69.1.bb +0
-0meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ · line 52
Quoted 3 lines
meta/recipes-support/curl/curl_7.69.1.bb +0
-0@@ -50,6 +50,8 @@ SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ file://CVE-2023-27535-pre1.patch \ file://CVE-2023-27535.patch \ file://CVE-2023-27536.patch \Shouldn't you be adding CVE-2023-28320-pre1.patch here?
Steve
Quoted 17 lines
meta/recipes-support/curl/curl_7.69.1.bb +2
-1+ file://CVE-2023-28320.patch \ + file://CVE-2023-28320-fol1.patch \ " SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42" --2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#184058): https://lists.openembedded.org/g/openembedded-core/message/184058
Mute This Topic: https://lists.openembedded.org/mt/100053064/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Corrected, v2 has been sent for review.
Kind regards,
Vivek
Quoted 632 lines · Steve Sakoman
Quoted 4 lines · Vivek Kumbhar
As it is a followup patch I have added it as fol1.
If you want this as pre1, I will send v2 again.
What is confusing me is that this patch adds three files (CVE-2023-28320-fol1.patch, CVE-2023-28320-pre1.patch, CVE-2023-28320.patch) but then only adds two of them to
SRC_URI.So you should either drop adding CVE-2023-28320-pre1.patch, or add it to
SRC_URI.Make sense?
Steve
Quoted 5 lines · Steve Sakoman
Quoted 4 lines · vkumbhar
Quoted 2 lines
Introduced by:
https://github.com/curl/curl/commit/3c49b405de4fbf1fd7127f91908261268640e54f
(curl-7_9_8)Quoted 1 line
Quoted 1 line
Quoted 1 line
Fixed by:
https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2
(curl-8_1_0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Follow-up:
https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
(curl-8_1_0)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
https://curl.se/docs/CVE-2023-28320.html
Signed-off-by Vivek Kumbhar <[email protected]>--- .../curl/curl/CVE-2023-28320-fol1.patch | 197++++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
.../curl/curl/CVE-2023-28320-pre1.patch | 197++++++++++++++++++
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
.../curl/curl/CVE-2023-28320.patch | 86 ++++++++ meta/recipes-support/curl/curl_7.69.1.bb | 2 + 4 files changed, 482 insertions(+) create mode 100644
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patchQuoted 1 line
Quoted 1 line
Quoted 1 line
create mode 100644
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patchQuoted 1 line
Quoted 1 line
Quoted 1 line
create mode 100644
meta/recipes-support/curl/curl/CVE-2023-28320.patchQuoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patchQuoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 1
Quoted 6 lines
new file mode 100644
index 0000000000..eaa6fdc327meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +1
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:002001
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +6
-0+From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined.Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0+ +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
]Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +6
-0+ lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.hQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 32
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +7
-0+new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H++/***************************************************************************
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +5
-0++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____|Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distributeand/or sell
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 46
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +1
-0++ * copies of the Software, and permit persons to whom the Softwareis
Quoted 3 lines
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +3
-0++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUTWARRANTY OF ANY
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 56
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +5
-0++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++***************************************************************************/
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFEQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MSdefine */
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +22
-0++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* liesin its
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +56
-0++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0+ #define USE_ALARM_TIMEOUT + #endif + +-#ifdef USE_ALARM_TIMEOUT +-#include "easy_lock.h" +-#endif +- + #define MAX_HOSTCACHE_LEN (255 + 7) /* max FQDN + colon + portnumber + zero */
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0+ + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* Beware this is a global and unique instance. This is used tostore the
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch line 165
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +5
-0+ is not thread-safe stuff. */ +-sigjmp_buf curl_jmpenv; +-curl_simple_lock curl_jmpenv_lock; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock;Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0+ #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data,
Curl_addrinfo*addr,Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +6
-0+ #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. Beware this +- * is a global and unique instance. This is used to store the returnQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +8
-0+- * address that we can jump back to from inside a signal handler. +- * This is not thread-safe stuff. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers touse.
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-fol1.patch new file +4
-0+ */ +-- +2.25.1 +(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patchQuoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 1
Quoted 6 lines
new file mode 100644
index 0000000000..eaa6fdc327meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +1
-0@@ -0,0 +1,197 @@ +From f446258f0269a62289cca0210157cb8558d0edc3 Mon Sep 17 00:00:002001
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +6
-0+From: Daniel Stenberg <[email protected]> +Date: Tue, 16 May 2023 23:40:42 +0200 +Subject: [PATCH] hostip: include easy_lock.h before using + GLOBAL_INIT_IS_THREADSAFE + +Since that header file is the only place that define can be defined.Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 15
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0+ +Reported-by: Marc Deslauriers + +Follow-up to 13718030ad4b3209 + +Closes #11121 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/f446258f0269a62289cca0210157cb8558d0edc3
]Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 19
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/easy_lock.h | 109++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +6
-0+ lib/hostip.c | 10 ++--- + lib/hostip.h | 9 ---- + 3 files changed, 113 insertions(+), 15 deletions(-) + create mode 100644 lib/easy_lock.h + +diff --git a/lib/easy_lock.h b/lib/easy_lock.hQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 32
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +7
-0+new file mode 100644 +index 0000000..6399a39 +--- /dev/null ++++ b/lib/easy_lock.h +@@ -0,0 +1,109 @@ ++#ifndef HEADER_CURL_EASY_LOCK_H ++#define HEADER_CURL_EASY_LOCK_H++/***************************************************************************
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +5
-0++ * _ _ ____ _ ++ * Project ___| | | | _ \| | ++ * / __| | | | |_) | | ++ * | (__| |_| | _ <| |___ ++ * \___|\___/|_| \_\_____|Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 45
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0++ * ++ * Copyright (C) Daniel Stenberg, <[email protected]>, et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distributeand/or sell
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 46
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +1
-0++ * copies of the Software, and permit persons to whom the Softwareis
Quoted 3 lines
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 49
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +3
-0++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUTWARRANTY OF ANY
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 54
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +5
-0++ * KIND, either express or implied. ++ * ++ * SPDX-License-Identifier: curl ++ * ++***************************************************************************/
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0++ ++#include "curl_setup.h" ++ ++#define GLOBAL_INIT_IS_THREADSAFEQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 66
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0++ ++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 ++ ++#ifdef __MINGW32__ ++#ifndef __MINGW64_VERSION_MAJOR ++#if (__MINGW32_MAJOR_VERSION < 5) || \ ++ (__MINGW32_MAJOR_VERSION == 5 && __MINGW32_MINOR_VERSION == 0) ++/* mingw >= 5.0.1 defines SRWLOCK, and slightly different from MSdefine */
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +22
-0++typedef PVOID SRWLOCK, *PSRWLOCK; ++#endif ++#endif ++#ifndef SRWLOCK_INIT ++#define SRWLOCK_INIT NULL ++#endif ++#endif /* __MINGW32__ */ ++ ++#define curl_simple_lock SRWLOCK ++#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT ++ ++#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) ++#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) ++ ++#elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) ++#include <stdatomic.h> ++#if defined(HAVE_SCHED_YIELD) ++#include <sched.h> ++#endif ++ ++#define curl_simple_lock atomic_int ++#define CURL_SIMPLE_LOCK_INIT 0Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 96
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0++ ++/* a clang-thing */ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++#ifndef __INTEL_COMPILER ++/* The Intel compiler tries to look like GCC *and* clang *and* liesin its
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +56
-0++ __has_builtin() function, so override it. */ ++ ++/* if GCC on i386/x86_64 or if the built-in is present */ ++#if ( (defined(__GNUC__) && !defined(__clang__)) && \ ++ (defined(__i386__) || defined(__x86_64__))) || \ ++ __has_builtin(__builtin_ia32_pause) ++#define HAVE_BUILTIN_IA32_PAUSE ++#endif ++ ++#endif ++ ++static inline void curl_simple_lock_lock(curl_simple_lock *lock) ++{ ++ for(;;) { ++ if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) ++ break; ++ /* Reduce cache coherency traffic */ ++ while(atomic_load_explicit(lock, memory_order_relaxed)) { ++ /* Reduce load (not mandatory) */ ++#ifdef HAVE_BUILTIN_IA32_PAUSE ++ __builtin_ia32_pause(); ++#elif defined(__aarch64__) ++ __asm__ volatile("yield" ::: "memory"); ++#elif defined(HAVE_SCHED_YIELD) ++ sched_yield(); ++#endif ++ } ++ } ++} ++ ++static inline void curl_simple_lock_unlock(curl_simple_lock *lock) ++{ ++ atomic_store_explicit(lock, false, memory_order_release); ++} ++ ++#else ++ ++#undef GLOBAL_INIT_IS_THREADSAFE ++ ++#endif ++ ++#endif /* HEADER_CURL_EASY_LOCK_H */ +diff --git a/lib/hostip.c b/lib/hostip.c +index 5231a74..d5bf881 100644 +--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,6 +68,8 @@ + #include "curl_memory.h" + #include "memdebug.h" + ++#include "easy_lock.h" ++ + #if defined(CURLRES_SYNCH) && \ + defined(HAVE_ALARM) && \ + defined(SIGALRM) && \ +@@ -77,10 +79,6 @@Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 160
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0+ #define USE_ALARM_TIMEOUT + #endif + +-#ifdef USE_ALARM_TIMEOUT +-#include "easy_lock.h" +-#endif +- + #define MAX_HOSTCACHE_LEN (255 + 7) /* max FQDN + colon + portnumber + zero */
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 164
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0+ + /* +@@ -259,8 +257,8 @@ void Curl_hostcache_prune(struct Curl_easy *data) + /* Beware this is a global and unique instance. This is used tostore the
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 165
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +5
-0+ is not thread-safe stuff. */ +-sigjmp_buf curl_jmpenv; +-curl_simple_lock curl_jmpenv_lock; ++static sigjmp_buf curl_jmpenv; ++static curl_simple_lock curl_jmpenv_lock;Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 178
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0+ #endif + + /* lookup address, returns entry if found and not stale */ +diff --git a/lib/hostip.h b/lib/hostip.h +index baf1e58..d7f73d9 100644 +--- a/lib/hostip.h ++++ b/lib/hostip.h +@@ -196,15 +196,6 @@ Curl_cache_addr(struct Curl_easy *data,
Curl_addrinfo*addr,Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +6
-0+ #define CURL_INADDR_NONE INADDR_NONE + #endif + +-#ifdef HAVE_SIGSETJMP +-/* Forward-declaration of variable defined in hostip.c. Beware this +- * is a global and unique instance. This is used to store the returnQuoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch line 192
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +8
-0+- * address that we can jump back to from inside a signal handler. +- * This is not thread-safe stuff. +- */ +-extern sigjmp_buf curl_jmpenv; +-#endif +- + /* + * Function provided by the resolver backend to set DNS servers touse.
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320-pre1.patch new file +4
-0+ */ +-- +2.25.1 +(quoted diff) +0
-0
b/meta/recipes-support/curl/curl/CVE-2023-28320.patchQuoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 1
Quoted 6 lines
new file mode 100644
index 0000000000..0c9b67440ameta/recipes-support/curl/curl/CVE-2023-28320.patch new file +1
-0@@ -0,0 +1,86 @@ +From 13718030ad4b3209a7583b4f27f683cd3a6fa5f2 Mon Sep 17 00:00:002001
Quoted 3 lines
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +3
-0+From: Harry Sintonen <[email protected]> +Date: Tue, 25 Apr 2023 09:22:26 +0200 +Subject: [PATCH] hostip: add locks around use of global buffer for
alarm()Quoted 7 lines
Quoted 7 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 7 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +7
-0+ +When building with the sync name resolver and timeout ability we now +require thread-safety to be present to enable it. + +Closes #11030 + +Upstream-Status: Backport [https://github.com/curl/curl/commit/13718030ad4b3209a7583b4f27f683cd3a6fa5f2
]Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +8
-0+CVE: CVE-2023-28320 +Signed-off-by: Vivek Kumbhar <[email protected]> +--- + lib/hostip.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/lib/hostip.c b/lib/hostip.c +index f5bb634..5231a74 100644Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +8
-0+--- a/lib/hostip.c ++++ b/lib/hostip.c +@@ -68,12 +68,19 @@ + #include "curl_memory.h" + #include "memdebug.h" + +-#if defined(CURLRES_SYNCH) && \ +- defined(HAVE_ALARM) && defined(SIGALRM) &&
defined(HAVE_SIGSETJMP)Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +6
-0++#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 dependenciessatisfied */
Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +8
-0+ #define USE_ALARM_TIMEOUT + #endif + ++#ifdef USE_ALARM_TIMEOUT ++#include "easy_lock.h" ++#endif ++ + #define MAX_HOSTCACHE_LEN (255 + 7) /* max FQDN + colon + portnumber + zero */
Quoted 3 lines
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 44
Quoted 3 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +3
-0+ + /* +@@ -248,11 +255,12 @@ void Curl_hostcache_prune(struct Curl_easy*data)
Quoted 6 lines
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +6
-0+ 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 tostore the
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 51
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +1
-0+ return address that we can jump back to from inside a signalhandler. This
Quoted 7 lines
Quoted 7 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 7 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +7
-0+ 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 */ +@@ -614,7 +622,6 @@ enum resolve_t Curl_resolv(struct connectdata*conn,
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +4
-0+ static + RETSIGTYPE alarmfunc(int sig) + { +- /* this is for "-ansi -Wall -pedantic" to stop complaining!(rabe) */
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 4 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +4
-0+ (void)sig; + siglongjmp(curl_jmpenv, 1); + } +@@ -695,6 +702,8 @@ enum resolve_t Curl_resolv_timeout(structconnectdata *conn,
Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 67
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +1
-0+ This should be the last thing we do before calling
Curl_resolv(),Quoted 1 line
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch line 68
Quoted 1 line
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +1
-0+ as otherwise we'd have to worry about variables that getmodified
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +5
-0+ 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 */Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch
Quoted 8 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +8
-0+ failf(data, "name lookup timed out"); +@@ -763,6 +772,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 wasbefore minus
Quoted 6 lines
Quoted 6 lines
Review
Quoted 6 lines
meta/recipes-support/curl/curl/CVE-2023-28320.patch new file +5
-0+ the time we spent until now! */ + if(prev_alarm) { +-- +2.25.1 +(quoted diff) +0
-0b/meta/recipes-support/curl/curl_7.69.1.bb
Quoted 4 lines
Quoted 4 lines
meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "
Quoted 4 lines
index
13ec117099..ce81df0f05100644meta/recipes-support/curl/curl_7.69.1.bb +0
-0@@ -50,6 +50,8 @@ SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \
Quoted 12 lines
Quoted 12 lines
meta/recipes-support/curl/curl_7.69.1.bb SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \ · line 52
Quoted 3 lines
meta/recipes-support/curl/curl_7.69.1.bb +0
-0file://CVE-2023-27535-pre1.patch \ file://CVE-2023-27535.patch \ file://CVE-2023-27536.patch \Shouldn't you be adding CVE-2023-28320-pre1.patch here?
Steve
Quoted 4 lines
meta/recipes-support/curl/curl_7.69.1.bb +2
-0+ file://CVE-2023-28320.patch \ + file://CVE-2023-28320-fol1.patch \ "Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-support/curl/curl_7.69.1.bb +0
-1SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42" --2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#184058):https://lists.openembedded.org/g/openembedded-core/message/184058
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/100053064/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsubQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-