diff mbox series

[scarthgap,RESEND] zlib: fix CVE-2026-85091

Message ID 20261202114735.1577393-1-joaomarcos.costa@bootlin.com
State Superseded, archived
Delegated to: Yoann Congal
Headers show
Series [scarthgap,RESEND] zlib: fix CVE-2026-85091 | expand

Commit Message

Joao Marcos Costa Dec. 2, 2026, 11:47 a.m. UTC
This vulnerability, marked as High [1], was fixed upstream [2] since
v1.4.

Backport the fix to zlib v1.3.1.

This was tested with the poc [3] mentioned in Debian's Security tracker
[4], which doesn't produce any heap-buffer-overflow errors. For reference,
this is the output of 'poc' without the fix:

==1190853==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f0496071800 at pc 0x7f04972b741d bp 0x7ffd3392d3b0 sp 0x7ffd3392cb70
WRITE of size 2 at 0x7f0496071800 thread T0
    #0 0x7f04972b741c in vsnprintf (/lib64/libasan.so.8+0xb741c) (BuildId: fd074f20195c3dc106c8f366d4cbad1efb955954)
    #1 0x000000410b23 in gzvprintf (...)/build/workspace/sources/zlib/gzwrite.c:407
    #2 0x00000041149a in gzprintf (...)/build/workspace/sources/zlib/gzwrite.c:435
    #3 0x000000400e20 in main (...)/build/workspace/sources/zlib/poc.c:44

[1] https://nvd.nist.gov/vuln/detail/CVE-2026-85091
[2] https://github.com/madler/zlib/commit/df84af25dc1942490e1d1c899a07619152a46148
[3] https://gist.github.com/thesmartshadow/e0b9481792afb7c31e86fee1ff084490
[4] https://security-tracker.debian.org/tracker/CVE-2026-85091

Signed-off-by: João Marcos Costa (Schneider Electric) <joaomarcos.costa@bootlin.com>
---
 .../zlib/zlib/CVE-2026-85091.patch            | 35 +++++++++++++++++++
 meta/recipes-core/zlib/zlib_1.3.1.bb          |  1 +
 2 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-core/zlib/zlib/CVE-2026-85091.patch

Comments

Joao Marcos Costa Dec. 2, 2026, 3:40 p.m. UTC | #1
Hello,

On 12/2/26 12:47 PM, João Marcos Costa (Schneider Electric) wrote:
> This vulnerability, marked as High [1], was fixed upstream [2] since
> v1.4.
> 
> Backport the fix to zlib v1.3.1.
(...)

That's actually a duplicated one...
Devansh P. sent this a week ago: 
https://lists.openembedded.org/g/openembedded-core/message/250994
Yoann Congal Dec. 2, 2026, 4:14 p.m. UTC | #2
Le mer. 2 déc. 2026 à 16:40, Joao Marcos Costa <joaomarcos.costa@bootlin.com>
a écrit :

> Hello,
>
> On 12/2/26 12:47 PM, João Marcos Costa (Schneider Electric) wrote:
> > This vulnerability, marked as High [1], was fixed upstream [2] since
> > v1.4.
> >
> > Backport the fix to zlib v1.3.1.
> (...)
>
> That's actually a duplicated one...
> Devansh P. sent this a week ago:
> https://lists.openembedded.org/g/openembedded-core/message/250994


Thanks for the heads-up :)

Regards,

>
>
> --
> Best regards,
> João Marcos Costa
>
>
diff mbox series

Patch

diff --git a/meta/recipes-core/zlib/zlib/CVE-2026-85091.patch b/meta/recipes-core/zlib/zlib/CVE-2026-85091.patch
new file mode 100644
index 0000000000..896971683c
--- /dev/null
+++ b/meta/recipes-core/zlib/zlib/CVE-2026-85091.patch
@@ -0,0 +1,35 @@ 
+From b75b8c6be592a4e16f2b8dbdb11e79e448ab85a3 Mon Sep 17 00:00:00 2001
+From: Mark Adler <git@madler.net>
+Date: Wed, 16 Sep 2026 16:26:14 -0700
+Subject: [PATCH] Fix buffer overflow bug in non-blocking gzwrite.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This addresses CVE-2026-85091.
+
+CVE: CVE-2026-85091
+Upstream-Status: Backport [https://github.com/madler/zlib/commit/df84af25dc1942490e1d1c899a07619152a46148]
+
+Signed-off-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
+---
+ gzwrite.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/gzwrite.c b/gzwrite.c
+index 435b462..fd340f0 100644
+--- a/gzwrite.c
++++ b/gzwrite.c
+@@ -223,8 +223,11 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
+                 n = (unsigned)len;
+             state->strm.avail_in = n;
+             state->x.pos += n;
+-            if (gz_comp(state, Z_NO_FLUSH) == -1)
++            if (gz_comp(state, Z_NO_FLUSH) == -1) {
++                state->strm.avail_in = 0;
++                state->strm.next_in = state->in;
+                 return 0;
++            }
+             len -= n;
+         } while (len);
+     }
diff --git a/meta/recipes-core/zlib/zlib_1.3.1.bb b/meta/recipes-core/zlib/zlib_1.3.1.bb
index e42578fd7e..bfcf8ea2ee 100644
--- a/meta/recipes-core/zlib/zlib_1.3.1.bb
+++ b/meta/recipes-core/zlib/zlib_1.3.1.bb
@@ -11,6 +11,7 @@  SRC_URI = "https://zlib.net/${BP}.tar.gz \
            file://0001-configure-Pass-LDFLAGS-to-link-tests.patch \
            file://run-ptest \
            file://CVE-2026-27171.patch \
+           file://CVE-2026-85091.patch \
            "
 UPSTREAM_CHECK_URI = "http://zlib.net/"