summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2021-04-07 21:55:18 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-04-23 10:41:21 +0100
commit18cbfe6369200df6c712c94af28aa752f789e283 (patch)
tree20826acf9feee818ba1422d83a5b2c49bb4e15d6
parent207c859da924844cd5d1b8d35a8cf0cda3fc680e (diff)
downloadpoky-18cbfe6369200df6c712c94af28aa752f789e283.tar.gz
busybox: fix CVE-2021-28831
Backport patch to fix CVE-2021-28831. (From OE-Core rev: 147a08dced5e565f19f4987a3c199780dc00f878) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit e579dbd9a6b2472ca90f411c0b594da9e38c9aca) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/busybox/busybox/0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch58
-rw-r--r--meta/recipes-core/busybox/busybox_1.32.0.bb3
2 files changed, 60 insertions, 1 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch b/meta/recipes-core/busybox/busybox/0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch
new file mode 100644
index 0000000000..67c9f189cc
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch
@@ -0,0 +1,58 @@
1From fe791386ebc270219ca00406c9fdadc5130b64ee Mon Sep 17 00:00:00 2001
2From: Samuel Sapalski <samuel.sapalski@nokia.com>
3Date: Wed, 3 Mar 2021 16:31:22 +0100
4Subject: [PATCH] decompress_gunzip: Fix DoS if gzip is corrupt
5
6On certain corrupt gzip files, huft_build will set the error bit on
7the result pointer. If afterwards abort_unzip is called huft_free
8might run into a segmentation fault or an invalid pointer to
9free(p).
10
11In order to mitigate this, we check in huft_free if the error bit
12is set and clear it before the linked list is freed.
13
14Signed-off-by: Samuel Sapalski <samuel.sapalski@nokia.com>
15Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
16Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
17
18Upstream-Status: Backport
19CVE: CVE-2021-28831
20Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
21---
22 archival/libarchive/decompress_gunzip.c | 12 ++++++++++--
23 1 file changed, 10 insertions(+), 2 deletions(-)
24
25diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c
26index eb3b64930..e93cd5005 100644
27--- a/archival/libarchive/decompress_gunzip.c
28+++ b/archival/libarchive/decompress_gunzip.c
29@@ -220,10 +220,20 @@ static const uint8_t border[] ALIGN1 = {
30 * each table.
31 * t: table to free
32 */
33+#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
34+#define ERR_RET ((huft_t*)(uintptr_t)1)
35 static void huft_free(huft_t *p)
36 {
37 huft_t *q;
38
39+ /*
40+ * If 'p' has the error bit set we have to clear it, otherwise we might run
41+ * into a segmentation fault or an invalid pointer to free(p)
42+ */
43+ if (BAD_HUFT(p)) {
44+ p = (huft_t*)((uintptr_t)(p) ^ (uintptr_t)(ERR_RET));
45+ }
46+
47 /* Go through linked list, freeing from the malloced (t[-1]) address. */
48 while (p) {
49 q = (--p)->v.t;
50@@ -289,8 +299,6 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
51 * or a valid pointer to a Huffman table, ORed with 0x1 if incompete table
52 * is given: "fixed inflate" decoder feeds us such data.
53 */
54-#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
55-#define ERR_RET ((huft_t*)(uintptr_t)1)
56 static huft_t* huft_build(const unsigned *b, const unsigned n,
57 const unsigned s, const struct cp_ext *cp_ext,
58 unsigned *m)
diff --git a/meta/recipes-core/busybox/busybox_1.32.0.bb b/meta/recipes-core/busybox/busybox_1.32.0.bb
index 8e23b0d4a2..b91f7cf711 100644
--- a/meta/recipes-core/busybox/busybox_1.32.0.bb
+++ b/meta/recipes-core/busybox/busybox_1.32.0.bb
@@ -46,7 +46,8 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
46 file://0001-hwclock-make-glibc-2.31-compatible.patch \ 46 file://0001-hwclock-make-glibc-2.31-compatible.patch \
47 file://rev.cfg \ 47 file://rev.cfg \
48 file://pgrep.cfg \ 48 file://pgrep.cfg \
49" 49 file://0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch \
50 "
50SRC_URI_append_libc-musl = " file://musl.cfg " 51SRC_URI_append_libc-musl = " file://musl.cfg "
51 52
52SRC_URI[tarball.md5sum] = "9576986f1a960da471d03b72a62f13c7" 53SRC_URI[tarball.md5sum] = "9576986f1a960da471d03b72a62f13c7"