diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2021-04-07 21:55:18 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-18 11:37:24 +0100 |
commit | bbec2f3f2928abf09bb37c897686e488858e59de (patch) | |
tree | cbe3d1a8619d261fa81ca16f7a0e8941ab7c52d2 | |
parent | cf80f79422243906d373861c7dc8f50e5abaf01b (diff) | |
download | poky-bbec2f3f2928abf09bb37c897686e488858e59de.tar.gz |
busybox: fix CVE-2021-28831
Backport patch to fix CVE-2021-28831.
(From OE-Core rev: e579dbd9a6b2472ca90f411c0b594da9e38c9aca)
Signed-off-by: Chen Qi <Qi.Chen@windriver.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.patch | 58 | ||||
-rw-r--r-- | meta/recipes-core/busybox/busybox_1.33.0.bb | 3 |
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 @@ | |||
1 | From fe791386ebc270219ca00406c9fdadc5130b64ee Mon Sep 17 00:00:00 2001 | ||
2 | From: Samuel Sapalski <samuel.sapalski@nokia.com> | ||
3 | Date: Wed, 3 Mar 2021 16:31:22 +0100 | ||
4 | Subject: [PATCH] decompress_gunzip: Fix DoS if gzip is corrupt | ||
5 | |||
6 | On certain corrupt gzip files, huft_build will set the error bit on | ||
7 | the result pointer. If afterwards abort_unzip is called huft_free | ||
8 | might run into a segmentation fault or an invalid pointer to | ||
9 | free(p). | ||
10 | |||
11 | In order to mitigate this, we check in huft_free if the error bit | ||
12 | is set and clear it before the linked list is freed. | ||
13 | |||
14 | Signed-off-by: Samuel Sapalski <samuel.sapalski@nokia.com> | ||
15 | Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com> | ||
16 | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> | ||
17 | |||
18 | Upstream-Status: Backport | ||
19 | CVE: CVE-2021-28831 | ||
20 | Signed-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 | |||
25 | diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c | ||
26 | index 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.33.0.bb b/meta/recipes-core/busybox/busybox_1.33.0.bb index 1a3f218bca..58e9cf7fce 100644 --- a/meta/recipes-core/busybox/busybox_1.33.0.bb +++ b/meta/recipes-core/busybox/busybox_1.33.0.bb | |||
@@ -46,7 +46,8 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ | |||
46 | file://0001-sysctl-ignore-EIO-of-stable_secret-below-proc-sys-ne.patch \ | 46 | file://0001-sysctl-ignore-EIO-of-stable_secret-below-proc-sys-ne.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 | " | ||
50 | SRC_URI_append_libc-musl = " file://musl.cfg " | 51 | SRC_URI_append_libc-musl = " file://musl.cfg " |
51 | 52 | ||
52 | SRC_URI[tarball.sha256sum] = "d568681c91a85edc6710770cebc1e80e042ad74d305b5c2e6d57a5f3de3b8fbd" | 53 | SRC_URI[tarball.sha256sum] = "d568681c91a85edc6710770cebc1e80e042ad74d305b5c2e6d57a5f3de3b8fbd" |