* + lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch added to mm-nonmm-unstable branch
@ 2023-02-23 20:54 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-02-23 20:54 UTC (permalink / raw)
To: mm-commits, iii, hca, gor, zaslonko, akpm
The patch titled
Subject: lib/zlib: DFLTCC deflate does not write all available bits for Z_NO_FLUSH
has been added to the -mm mm-nonmm-unstable branch. Its filename is
lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Mikhail Zaslonko <zaslonko@linux.ibm.com>
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
Link: https://lkml.kernel.org/r/20230221131617.3369978-2-zaslonko@linux.ibm.com
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/zlib_deflate/defutil.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/lib/zlib_deflate/defutil.h~lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush
+++ a/lib/zlib_deflate/defutil.h
@@ -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 zaslonko@linux.ibm.com are
lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-23 20:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-23 20:54 + lib-zlib-dfltcc-deflate-does-not-write-all-available-bits-for-z_no_flush.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.