summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-extended/redis/redis-7.0.13/CVE-2023-41056.patch63
-rw-r--r--meta-oe/recipes-extended/redis/redis_7.0.13.bb1
2 files changed, 64 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/redis/redis-7.0.13/CVE-2023-41056.patch b/meta-oe/recipes-extended/redis/redis-7.0.13/CVE-2023-41056.patch
new file mode 100644
index 0000000000..036e62c8f0
--- /dev/null
+++ b/meta-oe/recipes-extended/redis/redis-7.0.13/CVE-2023-41056.patch
@@ -0,0 +1,63 @@
1From e351099e1119fb89496be578f5232c61ce300224 Mon Sep 17 00:00:00 2001
2From: Oran Agra <oran@redislabs.com>
3Date: Sun, 7 Jan 2024 12:32:44 +0200
4Subject: [PATCH] Fix possible corruption in sdsResize (CVE-2023-41056)
5
6#11766 introduced a bug in sdsResize where it could forget to update
7the sds type in the sds header and then cause an overflow in sdsalloc.
8it looks like the only implication of that is a possible assertion in HLL,
9but it's hard to rule out possible heap corruption issues with clientsCronResizeQueryBuffer
10
11CVE: CVE-2023-41056
12
13Upstream-Status: Backport [https://github.com/redis/redis/commit/e351099e1119fb89496be578f5232c61ce300224]
14
15Signed-off-by: Divya Chellam <divya.chellam@windriver.com>
16---
17 src/sds.c | 30 ++++++++++++++++--------------
18 1 file changed, 16 insertions(+), 14 deletions(-)
19
20diff --git a/src/sds.c b/src/sds.c
21index 8e5863a..71490d5 100644
22--- a/src/sds.c
23+++ b/src/sds.c
24@@ -348,20 +348,22 @@ sds sdsResize(sds s, size_t size, int would_regrow) {
25 * type. */
26 int use_realloc = (oldtype==type || (type < oldtype && type > SDS_TYPE_8));
27 size_t newlen = use_realloc ? oldhdrlen+size+1 : hdrlen+size+1;
28- int alloc_already_optimal = 0;
29- #if defined(USE_JEMALLOC)
30- /* je_nallocx returns the expected allocation size for the newlen.
31- * We aim to avoid calling realloc() when using Jemalloc if there is no
32- * change in the allocation size, as it incurs a cost even if the
33- * allocation size stays the same. */
34- alloc_already_optimal = (je_nallocx(newlen, 0) == zmalloc_size(sh));
35- #endif
36-
37- if (use_realloc && !alloc_already_optimal) {
38- newsh = s_realloc(sh, newlen);
39- if (newsh == NULL) return NULL;
40- s = (char*)newsh+oldhdrlen;
41- } else if (!alloc_already_optimal) {
42+
43+ if (use_realloc) {
44+ int alloc_already_optimal = 0;
45+ #if defined(USE_JEMALLOC)
46+ /* je_nallocx returns the expected allocation size for the newlen.
47+ * We aim to avoid calling realloc() when using Jemalloc if there is no
48+ * change in the allocation size, as it incurs a cost even if the
49+ * allocation size stays the same. */
50+ alloc_already_optimal = (je_nallocx(newlen, 0) == zmalloc_size(sh));
51+ #endif
52+ if (!alloc_already_optimal) {
53+ newsh = s_realloc(sh, newlen);
54+ if (newsh == NULL) return NULL;
55+ s = (char*)newsh+oldhdrlen;
56+ }
57+ } else {
58 newsh = s_malloc(newlen);
59 if (newsh == NULL) return NULL;
60 memcpy((char*)newsh+hdrlen, s, len);
61--
622.40.0
63
diff --git a/meta-oe/recipes-extended/redis/redis_7.0.13.bb b/meta-oe/recipes-extended/redis/redis_7.0.13.bb
index e88ab4ddf5..dc5f9b7a89 100644
--- a/meta-oe/recipes-extended/redis/redis_7.0.13.bb
+++ b/meta-oe/recipes-extended/redis/redis_7.0.13.bb
@@ -16,6 +16,7 @@ SRC_URI = "http://download.redis.io/releases/${BP}.tar.gz \
16 file://0001-src-Do-not-reset-FINAL_LIBS.patch \ 16 file://0001-src-Do-not-reset-FINAL_LIBS.patch \
17 file://GNU_SOURCE-7.patch \ 17 file://GNU_SOURCE-7.patch \
18 file://0006-Define-correct-gregs-for-RISCV32.patch \ 18 file://0006-Define-correct-gregs-for-RISCV32.patch \
19 file://CVE-2023-41056.patch \
19 " 20 "
20SRC_URI[sha256sum] = "97065774d5fb8388eb0d8913458decfcb167d356e40d31dd01cd30c1cc391673" 21SRC_URI[sha256sum] = "97065774d5fb8388eb0d8913458decfcb167d356e40d31dd01cd30c1cc391673"
21 22