summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDivya Chellam <divya.chellam@windriver.com>2025-07-08 15:53:53 +0530
committerSteve Sakoman <steve@sakoman.com>2025-07-17 13:57:58 -0700
commit0d07e2b9148c7e726afc37fa9601b876d3eae375 (patch)
treed4651b66d87dfab612de1ee200b0e7bef2e32d8a
parent9613e1167e2d06e65f21f6e59719d4008904cb21 (diff)
downloadpoky-0d07e2b9148c7e726afc37fa9601b876d3eae375.tar.gz
libarchive: fix CVE-2025-5915
A vulnerability has been identified in the libarchive library. This flaw can lead to a heap b uffer over-read due to the size of a filter block potentially exceeding the Lempel-Ziv-Storer -Schieber (LZSS) window. This means the library may attempt to read beyond the allocated memo ry buffer, which can result in unpredictable program behavior, crashes (denial of service), o r the disclosure of sensitive information from adjacent memory regions. Adjusted indentation in the recipe file. Reference: https://security-tracker.debian.org/tracker/CVE-2025-5915 Upstream-patches: https://github.com/libarchive/libarchive/commit/a612bf62f86a6faa47bd57c52b94849f0a404d8c (From OE-Core rev: 0787eb4ed528cde09ed8f27f070cc6875548f056) Signed-off-by: Divya Chellam <divya.chellam@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-extended/libarchive/libarchive/CVE-2025-5915.patch217
-rw-r--r--meta/recipes-extended/libarchive/libarchive_3.7.9.bb5
2 files changed, 220 insertions, 2 deletions
diff --git a/meta/recipes-extended/libarchive/libarchive/CVE-2025-5915.patch b/meta/recipes-extended/libarchive/libarchive/CVE-2025-5915.patch
new file mode 100644
index 0000000000..3c911ce9d9
--- /dev/null
+++ b/meta/recipes-extended/libarchive/libarchive/CVE-2025-5915.patch
@@ -0,0 +1,217 @@
1From a612bf62f86a6faa47bd57c52b94849f0a404d8c Mon Sep 17 00:00:00 2001
2From: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
3Date: Sun, 11 May 2025 19:00:11 +0200
4Subject: [PATCH] rar: Fix heap-buffer-overflow (#2599)
5
6A filter block size must not be larger than the lzss window, which is
7defined
8by dictionary size, which in turn can be derived from unpacked file
9size.
10
11While at it, improve error messages and fix lzss window wrap around
12logic.
13
14Fixes https://github.com/libarchive/libarchive/issues/2565
15
16---------
17
18Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
19Co-authored-by: Tim Kientzle <kientzle@acm.org>
20
21CVE: CVE-2025-5915
22
23Upstream-Status: Backport [https://github.com/libarchive/libarchive/commit/a612bf62f86a6faa47bd57c52b94849f0a404d8c]
24
25Signed-off-by: Divya Chellam <divya.chellam@windriver.com>
26---
27 Makefile.am | 2 +
28 libarchive/archive_read_support_format_rar.c | 17 ++++---
29 libarchive/test/CMakeLists.txt | 1 +
30 .../test/test_read_format_rar_overflow.c | 48 +++++++++++++++++++
31 .../test/test_read_format_rar_overflow.rar.uu | 11 +++++
32 5 files changed, 72 insertions(+), 7 deletions(-)
33 create mode 100644 libarchive/test/test_read_format_rar_overflow.c
34 create mode 100644 libarchive/test/test_read_format_rar_overflow.rar.uu
35
36diff --git a/Makefile.am b/Makefile.am
37index 4fafc41..9f3a6d1 100644
38--- a/Makefile.am
39+++ b/Makefile.am
40@@ -519,6 +519,7 @@ libarchive_test_SOURCES= \
41 libarchive/test/test_read_format_rar_encryption_header.c \
42 libarchive/test/test_read_format_rar_filter.c \
43 libarchive/test/test_read_format_rar_invalid1.c \
44+ libarchive/test/test_read_format_rar_overflow.c \
45 libarchive/test/test_read_format_rar5.c \
46 libarchive/test/test_read_format_raw.c \
47 libarchive/test/test_read_format_tar.c \
48@@ -889,6 +890,7 @@ libarchive_test_EXTRA_DIST=\
49 libarchive/test/test_read_format_rar_multivolume.part0003.rar.uu \
50 libarchive/test/test_read_format_rar_multivolume.part0004.rar.uu \
51 libarchive/test/test_read_format_rar_noeof.rar.uu \
52+ libarchive/test/test_read_format_rar_overflow.rar.uu \
53 libarchive/test/test_read_format_rar_ppmd_lzss_conversion.rar.uu \
54 libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu \
55 libarchive/test/test_read_format_rar_ppmd_use_after_free2.rar.uu \
56diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c
57index 9eb3c84..88eab62 100644
58--- a/libarchive/archive_read_support_format_rar.c
59+++ b/libarchive/archive_read_support_format_rar.c
60@@ -451,7 +451,7 @@ static int read_filter(struct archive_read *, int64_t *);
61 static int rar_decode_byte(struct archive_read*, uint8_t *);
62 static int execute_filter(struct archive_read*, struct rar_filter *,
63 struct rar_virtual_machine *, size_t);
64-static int copy_from_lzss_window(struct archive_read *, void *, int64_t, int);
65+static int copy_from_lzss_window(struct archive_read *, uint8_t *, int64_t, int);
66 static inline void vm_write_32(struct rar_virtual_machine*, size_t, uint32_t);
67 static inline uint32_t vm_read_32(struct rar_virtual_machine*, size_t);
68
69@@ -2929,7 +2929,7 @@ expand(struct archive_read *a, int64_t *end)
70 }
71
72 if ((symbol = read_next_symbol(a, &rar->maincode)) < 0)
73- return (ARCHIVE_FATAL);
74+ goto bad_data;
75
76 if (symbol < 256)
77 {
78@@ -2956,14 +2956,14 @@ expand(struct archive_read *a, int64_t *end)
79 else
80 {
81 if (parse_codes(a) != ARCHIVE_OK)
82- return (ARCHIVE_FATAL);
83+ goto bad_data;
84 continue;
85 }
86 }
87 else if(symbol==257)
88 {
89 if (!read_filter(a, end))
90- return (ARCHIVE_FATAL);
91+ goto bad_data;
92 continue;
93 }
94 else if(symbol==258)
95@@ -3048,7 +3048,7 @@ expand(struct archive_read *a, int64_t *end)
96 {
97 if ((lowoffsetsymbol =
98 read_next_symbol(a, &rar->lowoffsetcode)) < 0)
99- return (ARCHIVE_FATAL);
100+ goto bad_data;
101 if(lowoffsetsymbol == 16)
102 {
103 rar->numlowoffsetrepeats = 15;
104@@ -3096,7 +3096,7 @@ bad_data:
105 }
106
107 static int
108-copy_from_lzss_window(struct archive_read *a, void *buffer,
109+copy_from_lzss_window(struct archive_read *a, uint8_t *buffer,
110 int64_t startpos, int length)
111 {
112 int windowoffs, firstpart;
113@@ -3111,7 +3111,7 @@ copy_from_lzss_window(struct archive_read *a, void *buffer,
114 }
115 if (firstpart < length) {
116 memcpy(buffer, &rar->lzss.window[windowoffs], firstpart);
117- memcpy(buffer, &rar->lzss.window[0], length - firstpart);
118+ memcpy(buffer + firstpart, &rar->lzss.window[0], length - firstpart);
119 } else {
120 memcpy(buffer, &rar->lzss.window[windowoffs], length);
121 }
122@@ -3266,6 +3266,9 @@ parse_filter(struct archive_read *a, const uint8_t *bytes, uint16_t length, uint
123 else
124 blocklength = prog ? prog->oldfilterlength : 0;
125
126+ if (blocklength > rar->dictionary_size)
127+ return 0;
128+
129 registers[3] = PROGRAM_SYSTEM_GLOBAL_ADDRESS;
130 registers[4] = blocklength;
131 registers[5] = prog ? prog->usagecount : 0;
132diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt
133index 5d7a5d2..59c5f5d 100644
134--- a/libarchive/test/CMakeLists.txt
135+++ b/libarchive/test/CMakeLists.txt
136@@ -163,6 +163,7 @@ IF(ENABLE_TEST)
137 test_read_format_rar_encryption_partially.c
138 test_read_format_rar_invalid1.c
139 test_read_format_rar_filter.c
140+ test_read_format_rar_overflow.c
141 test_read_format_rar5.c
142 test_read_format_raw.c
143 test_read_format_tar.c
144diff --git a/libarchive/test/test_read_format_rar_overflow.c b/libarchive/test/test_read_format_rar_overflow.c
145new file mode 100644
146index 0000000..b39ed6b
147--- /dev/null
148+++ b/libarchive/test/test_read_format_rar_overflow.c
149@@ -0,0 +1,48 @@
150+/*-
151+ * Copyright (c) 2003-2025 Tim Kientzle
152+ * All rights reserved.
153+ *
154+ * Redistribution and use in source and binary forms, with or without
155+ * modification, are permitted provided that the following conditions
156+ * are met:
157+ * 1. Redistributions of source code must retain the above copyright
158+ * notice, this list of conditions and the following disclaimer.
159+ * 2. Redistributions in binary form must reproduce the above copyright
160+ * notice, this list of conditions and the following disclaimer in the
161+ * documentation and/or other materials provided with the distribution.
162+ *
163+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
164+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
165+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
166+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
167+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
168+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
169+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
170+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
171+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
172+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173+ */
174+#include "test.h"
175+
176+DEFINE_TEST(test_read_format_rar_overflow)
177+{
178+ struct archive *a;
179+ struct archive_entry *ae;
180+ const char reffile[] = "test_read_format_rar_overflow.rar";
181+ const void *buff;
182+ size_t size;
183+ int64_t offset;
184+
185+ extract_reference_file(reffile);
186+ assert((a = archive_read_new()) != NULL);
187+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
188+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
189+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, reffile, 1024));
190+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
191+ assertEqualInt(48, archive_entry_size(ae));
192+ /* The next call should reproduce Issue #2565 */
193+ assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data_block(a, &buff, &size, &offset));
194+
195+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
196+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
197+}
198diff --git a/libarchive/test/test_read_format_rar_overflow.rar.uu b/libarchive/test/test_read_format_rar_overflow.rar.uu
199new file mode 100644
200index 0000000..48fd3fd
201--- /dev/null
202+++ b/libarchive/test/test_read_format_rar_overflow.rar.uu
203@@ -0,0 +1,11 @@
204+begin 644 test_read_format_rar_overflow.rar
205+M4F%R(1H'`,($=```(0`@`0``,`````(````````````S`0``````,`"_B%_:
206+MZ?^[:7``?S!!,`@P,KB@,T@RN33)MTEB@5Z3<`DP`K35`.0P63@P<,Q&0?#,
207+MA##,,",S,(@P,#,@##`&,#":(3`!,#"(`9HPS,,S13`P,#`P,*`PHPS,,S1A
208+M,!,!,#","9H@S12D#$PP!C`P`*'F03":,,T8H`@\,/DPJS!/,"30,#`3N%LP
209+MCQ6:S3"!,#LP22<-,$5%B"5B$S!)(&*>G#+@!`E`%0ODC])62=DO,)BYJX'P
210+M=/LPZ3!!008?%S`P,#`P,#`P,#`P,#`P,#`P,#`P2$PP,#`P03!(,#`P,#`&
211+M,`7),#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
212+-,#`P,#`P,#`P,#`P,```
213+`
214+end
215--
2162.40.0
217
diff --git a/meta/recipes-extended/libarchive/libarchive_3.7.9.bb b/meta/recipes-extended/libarchive/libarchive_3.7.9.bb
index 1fa61c3218..c091508799 100644
--- a/meta/recipes-extended/libarchive/libarchive_3.7.9.bb
+++ b/meta/recipes-extended/libarchive/libarchive_3.7.9.bb
@@ -30,8 +30,9 @@ PACKAGECONFIG[zstd] = "--with-zstd,--without-zstd,zstd,"
30EXTRA_OECONF += "--enable-largefile --without-iconv" 30EXTRA_OECONF += "--enable-largefile --without-iconv"
31 31
32SRC_URI = "https://libarchive.org/downloads/libarchive-${PV}.tar.gz \ 32SRC_URI = "https://libarchive.org/downloads/libarchive-${PV}.tar.gz \
33 file://CVE-2025-5914.patch \ 33 file://CVE-2025-5914.patch \
34 " 34 file://CVE-2025-5915.patch \
35 "
35 36
36UPSTREAM_CHECK_URI = "http://libarchive.org/" 37UPSTREAM_CHECK_URI = "http://libarchive.org/"
37 38