Skip to contentSkip to conversation

lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Feb 28, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: lib/zlib: DFLTCC deflate does not write all available bits for Z_NO_FLUSH
has been removed from the -mm tree. Its filename was
lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Mikhail Zaslonko <[email protected]>
Subject: lib/zlib: DFLTCC deflate does not write all available bits for Z_NO_FLUSH
Date: Tue, 21 Feb 2023 14:16:17 +0100

DFLTCC deflate with Z_NO_FLUSH might generate a corrupted stream when the output buffer is not large enough to fit all the deflate output at once. The problem takes place on closing the deflate block since flush_pending() might leave some output bits not written. Similar problem for software deflate with Z_BLOCK flush option (not supported by kernel zlib deflate) has been fixed a while ago in userspace zlib but the fix never got to the kernel.

Now flush_pending() flushes the bit buffer before copying out the byte buffer, in order to really flush as much as possible.

Currently there are no users of DFLTCC deflate with Z_NO_FLUSH option in the kernel so the problem remained hidden for a while.

This commit is based on the old zlib commit:
https://github.com/madler/zlib/commit/0b828b4

---

lib/zlib_deflate/defutil.h renamed from lib/zlib_deflate/defutil.h~lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush +3 -1
@@ -420,9 +420,11 @@ static inline void flush_pending(
 	z_streamp strm
 )
 {
+    unsigned len;
     deflate_state *s = (deflate_state *) strm->state;
-    unsigned len = s->pending;
 
+    bi_flush(s);
+    len = s->pending;
     if (len > strm->avail_out) len = strm->avail_out;
     if (len == 0) return;
 

_

Patches currently in -mm which might be from [email protected] are