From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283137; b=zgmbef6xdO79ebln1yAc6xZ8bE12ClFrzX0gu0pl/NR/ztvHI+uxsmK/PHvamAXRDtw+ bQuxXo9R3hvm0ZvE5tZOOIuzDopfBMl9nglGfAY7A8bDvCAigjmJ8whvP0M+RnXDKYwGT ZfntRG/NBx4037NhCs56eGYoShbli8nD9MY49ua3/whYqvjIfRB6yC/33R+Jrq1NmMlb3 QMZ6rGrk00NXvzmxq0hXyeoAWYLukNw6LtTytRl5rfMMXusSuiGBNq4rMkUir6g2CHdpX WkdNjYIVflmQI/Gq50yElQ7GfFNFQ3IMVaESmAZv8R3J/Inph1+12dm8nTZs9xZEdOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283137; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=p2frlnmpKqh96QBua/wDZr4UZDb6YRjvCekqNMYVuRo=; b=0sEa+IaqXFtf8Gt3PcX47nPDvwclW313Zn/aPENXbc0+KknbAu/rW9F1pLbY6UT2TEc4 sLLrigJx6MCDg7JT9WQV2eGbWUDXVw6hxkoQyfqCHWNPmkd15cuU/I7z82sAKQ5YfIrn9 VvZMVmdmDzomRqz/QAcOCM6z2OdZ5vSWtfVx+Vu9QOCXn0ZECF/PIbSfy/pemG7bET8TY gTj+8Fd0Xdf/y+jBMFG8hOANfK7DfTg9S3AWLRRRuTnfDpxqyjq+maFA8A7nmRSZGM+i1 mwd/vGXlSW3EfcXwzgk0k2f9H2/5TWtLMnSwHzBOUK9dlIuVm5tJrylUmXpY21i2BBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GG8tchSG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 423CA606A322 for ; Thu, 3 Dec 2026 07:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GG8tchSG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BCA41F00898; Thu, 3 Dec 2026 07:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796283137; bh=p2frlnmpKqh96QBua/wDZr4UZDb6YRjvCekqNMYVuRo=; h=From:Date:Subject:References:In-Reply-To:To; b=GG8tchSG9LsgRXumsCewC09fPjoUw7a+bhWU+fZnK5XsB+CdQ1HTF2b6Ge9gzDfJv uOia/U2RiP0MNSBIu335YFmVAWwzKkBiCPL1sQbPCApGcp4lqZEpyqP45kC1p4yKK9 xt/cqA47DAglvtwcWXDlDadEZgRIlIaiuyM5rqGE= From: Greg Kroah-Hartman Date: Thu, 03 Dec 2026 08:30:00 +0100 Subject: [PATCH 20/21] lib/zlib: update deflate to zlib 1.2.2.4 release X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261203-zlib-sync-v1-20-0d4ec56f1afb@linuxfoundation.org> References: <20261203-zlib-sync-v1-0-0d4ec56f1afb@linuxfoundation.org> In-Reply-To: <20261203-zlib-sync-v1-0-0d4ec56f1afb@linuxfoundation.org> To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman X-Mailer: b4 0.17-dev-73bef X-Developer-Signature: v=1; a=openpgp-sha256; l=6185; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=7nQhK/8497SQXu/v44M/7oHi7JNMZCEV6mL+5qTeyn4=; b=owGbwMvMwCRo6H6F97bub03G02pJDNmCUtkmdqkx3422n9X2WGA4afHssvAL+hbaa58kMAQta Ak+/j2qI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACbyoZJhwe6z9//PcI57qHuq darl/73MS+cEfmCYp3hc7YHunUvzg+SWSly+NYdHVv6RMwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Bring the kernel deflate code up to zlib 1.2.2.4: This involves: - make deflate_state.pending unsigned (uInt), it's a byte count that is compared against unsigned sizes everywhere. - cast tree[m].Len explicitly in the gen_bitlen() comparison - copy upstream's #if 0 draft of deflate_rle() (enabled in a later release) with kernel-style tally calls - fill_window() %%% marker comment Changes that were not relevant for our copy were the gzip header put_byte casts and gzindex type change as they are in code that the kernel didn't ever copy. The kernel is now in sync with zlib commit 9c3a5830218c ("zlib 1.2.2.4"). Signed-off-by: Greg Kroah-Hartman --- include/linux/zlib.h | 2 +- lib/zlib_deflate/deflate.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ lib/zlib_deflate/deftree.c | 4 +-- lib/zlib_deflate/defutil.h | 2 +- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/include/linux/zlib.h b/include/linux/zlib.h index 2220e8f4bc12..5ceb476f959c 100644 --- a/include/linux/zlib.h +++ b/include/linux/zlib.h @@ -32,7 +32,7 @@ #include -/* zlib deflate based on ZLIB_VERSION "1.2.2.3" */ +/* zlib deflate based on ZLIB_VERSION "1.2.2.4" */ /* zlib inflate based on ZLIB_VERSION "1.2.3" */ /* diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c index b2c8860d6591..26b934eb84d3 100644 --- a/lib/zlib_deflate/deflate.c +++ b/lib/zlib_deflate/deflate.c @@ -893,6 +893,7 @@ static void fill_window( later. (Using level 0 permanently is not an optimal usage of zlib, so we don't care about this pathological case.) */ + /* %%% avoid this when Z_RLE */ n = s->hash_size; p = &s->head[n]; do { @@ -1251,6 +1252,68 @@ static block_state deflate_slow( return flush == Z_FINISH ? finish_done : block_done; } +#if 0 +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +static block_state deflate_rle( + deflate_state *s, + int flush +) +{ + int bflush; /* set if current block must be flushed */ + uInt run; /* length of run */ + uInt max; /* maximum length of run */ + uInt prev; /* byte at distance one to match */ + Byte *scan; /* scan for end of run */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest encodable run. + */ + if (s->lookahead < MAX_MATCH) { + fill_window(s); + if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + run = 0; + if (s->strstart > 0) { /* if there is a previous byte, that is */ + max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; + scan = s->window + s->strstart - 1; + prev = *scan++; + do { + if (*scan++ != prev) + break; + } while (++run < max); + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (run >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, run); + bflush = zlib_tr_tally(s, 1, run - MIN_MATCH); + s->lookahead -= run; + s->strstart += run; + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + bflush = zlib_tr_tally (s, 0, s->window[s->strstart]); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif + int zlib_deflate_workspacesize(int windowBits, int memLevel) { if (windowBits < 0) /* undocumented feature: suppress zlib header */ diff --git a/lib/zlib_deflate/deftree.c b/lib/zlib_deflate/deftree.c index b98feac2d498..2ae58d219155 100644 --- a/lib/zlib_deflate/deftree.c +++ b/lib/zlib_deflate/deftree.c @@ -1,6 +1,6 @@ /* +++ trees.c */ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2004 Jean-loup Gailly + * Copyright (C) 1995-2005 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -418,7 +418,7 @@ static void gen_bitlen( while (n != 0) { m = s->heap[--h]; if (m > max_code) continue; - if (tree[m].Len != (unsigned) bits) { + if ((unsigned) tree[m].Len != (unsigned) bits) { Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); s->opt_len += ((long)bits - (long)tree[m].Len) *(long)tree[m].Freq; diff --git a/lib/zlib_deflate/defutil.h b/lib/zlib_deflate/defutil.h index 29fa51e32da1..98713d1b3f58 100644 --- a/lib/zlib_deflate/defutil.h +++ b/lib/zlib_deflate/defutil.h @@ -83,7 +83,7 @@ typedef struct deflate_state { Byte *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ Byte *pending_out; /* next pending byte to output to the stream */ - int pending; /* nb of bytes in the pending buffer */ + uInt pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ Byte method; /* STORED (for zip only) or DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ -- 2.56.1