diff options
| author | Khem Raj <raj.khem@gmail.com> | 2022-08-14 19:49:50 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-16 14:57:58 +0100 |
| commit | 70700eab9cca9daaccf4effbc4ff52cae55c619c (patch) | |
| tree | e1ffb720514cde4ad86025c052c96592804816ee | |
| parent | ef5488d7326090e9e78939f7624214b8868b16ae (diff) | |
| download | poky-70700eab9cca9daaccf4effbc4ff52cae55c619c.tar.gz | |
zlib: Resolve CVE-2022-37434
Backport needed fixes
CVE: CVE-2022-37434
(From OE-Core rev: f7f089a89a9ba83aa62e4ca1fe9a6b8649b29259)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Paul Eggleton <bluelightning@bluelightning.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-core/zlib/zlib/0001-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch b/meta/recipes-core/zlib/zlib/0001-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch new file mode 100644 index 0000000000..96ab563121 --- /dev/null +++ b/meta/recipes-core/zlib/zlib/0001-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Adler <fork@madler.net> | ||
| 3 | Date: Sat, 30 Jul 2022 15:51:11 -0700 | ||
| 4 | Subject: [PATCH] Fix a bug when getting a gzip header extra field with inflate(). | ||
| 5 | |||
| 6 | If the extra field was larger than the space the user provided with | ||
| 7 | inflateGetHeader(), and if multiple calls of inflate() delivered | ||
| 8 | the extra header data, then there could be a buffer overflow of the | ||
| 9 | provided space. This commit assures that provided space is not | ||
| 10 | exceeded. | ||
| 11 | |||
| 12 | CVE: CVE-2022-37434 | ||
| 13 | Upstream-Status: Backport [https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166be] | ||
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 15 | --- | ||
| 16 | inflate.c | 5 +++-- | ||
| 17 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/inflate.c b/inflate.c | ||
| 20 | index 7be8c63..7a72897 100644 | ||
| 21 | --- a/inflate.c | ||
| 22 | +++ b/inflate.c | ||
| 23 | @@ -763,9 +763,10 @@ int flush; | ||
| 24 | copy = state->length; | ||
| 25 | if (copy > have) copy = have; | ||
| 26 | if (copy) { | ||
| 27 | + len = state->head->extra_len - state->length; | ||
| 28 | if (state->head != Z_NULL && | ||
| 29 | - state->head->extra != Z_NULL) { | ||
| 30 | - len = state->head->extra_len - state->length; | ||
| 31 | + state->head->extra != Z_NULL && | ||
| 32 | + len < state->head->extra_max) { | ||
| 33 | zmemcpy(state->head->extra + len, next, | ||
| 34 | len + copy > state->head->extra_max ? | ||
| 35 | state->head->extra_max - len : copy); | ||
| 36 | -- | ||
| 37 | 2.37.2 | ||
| 38 | |||
diff --git a/meta/recipes-core/zlib/zlib/0001-Fix-extra-field-processing-bug-that-dereferences-NUL.patch b/meta/recipes-core/zlib/zlib/0001-Fix-extra-field-processing-bug-that-dereferences-NUL.patch new file mode 100644 index 0000000000..a0978c5f95 --- /dev/null +++ b/meta/recipes-core/zlib/zlib/0001-Fix-extra-field-processing-bug-that-dereferences-NUL.patch | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Adler <fork@madler.net> | ||
| 3 | Date: Mon, 8 Aug 2022 10:50:09 -0700 | ||
| 4 | Subject: [PATCH] Fix extra field processing bug that dereferences NULL | ||
| 5 | state->head. | ||
| 6 | |||
| 7 | The recent commit to fix a gzip header extra field processing bug | ||
| 8 | introduced the new bug fixed here. | ||
| 9 | |||
| 10 | CVE: CVE-2022-37434 | ||
| 11 | Upstream-Status: Backport [https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d] | ||
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 13 | --- | ||
| 14 | inflate.c | 4 ++-- | ||
| 15 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/inflate.c b/inflate.c | ||
| 18 | index 7a72897..2a3c4fe 100644 | ||
| 19 | --- a/inflate.c | ||
| 20 | +++ b/inflate.c | ||
| 21 | @@ -763,10 +763,10 @@ int flush; | ||
| 22 | copy = state->length; | ||
| 23 | if (copy > have) copy = have; | ||
| 24 | if (copy) { | ||
| 25 | - len = state->head->extra_len - state->length; | ||
| 26 | if (state->head != Z_NULL && | ||
| 27 | state->head->extra != Z_NULL && | ||
| 28 | - len < state->head->extra_max) { | ||
| 29 | + (len = state->head->extra_len - state->length) < | ||
| 30 | + state->head->extra_max) { | ||
| 31 | zmemcpy(state->head->extra + len, next, | ||
| 32 | len + copy > state->head->extra_max ? | ||
| 33 | state->head->extra_max - len : copy); | ||
| 34 | -- | ||
| 35 | 2.37.2 | ||
| 36 | |||
diff --git a/meta/recipes-core/zlib/zlib_1.2.12.bb b/meta/recipes-core/zlib/zlib_1.2.12.bb index 77e7a4937f..b999f13530 100644 --- a/meta/recipes-core/zlib/zlib_1.2.12.bb +++ b/meta/recipes-core/zlib/zlib_1.2.12.bb | |||
| @@ -12,6 +12,8 @@ SRC_URI = "https://zlib.net/${BP}.tar.xz \ | |||
| 12 | file://0001-configure-Pass-LDFLAGS-to-link-tests.patch \ | 12 | file://0001-configure-Pass-LDFLAGS-to-link-tests.patch \ |
| 13 | file://run-ptest \ | 13 | file://run-ptest \ |
| 14 | file://0001-Correct-incorrect-inputs-provided-to-the-CRC-functio.patch \ | 14 | file://0001-Correct-incorrect-inputs-provided-to-the-CRC-functio.patch \ |
| 15 | file://0001-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch \ | ||
| 16 | file://0001-Fix-extra-field-processing-bug-that-dereferences-NUL.patch \ | ||
| 15 | " | 17 | " |
| 16 | UPSTREAM_CHECK_URI = "http://zlib.net/" | 18 | UPSTREAM_CHECK_URI = "http://zlib.net/" |
| 17 | 19 | ||
