public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com,
	Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
	Laurent M Coquerel <laurent.m.coquerel@intel.com>
Subject: [PATCH] crypto: deflate - fix decompression window size
Date: Tue, 24 Mar 2026 18:08:58 +0000	[thread overview]
Message-ID: <20260324180905.120703-1-giovanni.cabiddu@intel.com> (raw)

deflate_decompress() initializes the inflate stream with windowBits set
to -DEFLATE_DEF_WINBITS (11 bits, 2KB window). Valid raw DEFLATE streams
allow window sizes up to MAX_WBITS (15 bits, 32KB).  Using a smaller
window than the one used during compression causes decompression to fail
for externally generated data. This might occur if data is compressed
with a compressor that is not deflate-generic (i.e. this
implementation).

Use -MAX_WBITS when calling zlib_inflateInit2() to accept all valid raw
DEFLATE streams. The inflate workspace allocated in deflate_alloc_stream()
is already sized using zlib_inflate_workspacesize(), which accounts for
the maximum window size, so no allocation change is needed.

Fixes: 08cabc7d3c86 ("crypto: deflate - Convert to acomp")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Laurent M Coquerel <laurent.m.coquerel@intel.com>
---
 crypto/deflate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/deflate.c b/crypto/deflate.c
index 46fc7def8d4c..d347e506e6c3 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -203,7 +203,7 @@ static int deflate_decompress(struct acomp_req *req)
 	s = crypto_acomp_lock_stream_bh(&deflate_streams);
 	ds = s->ctx;
 
-	err = zlib_inflateInit2(&ds->stream, -DEFLATE_DEF_WINBITS);
+	err = zlib_inflateInit2(&ds->stream, -MAX_WBITS);
 	if (err != Z_OK) {
 		err = -EINVAL;
 		goto out;
-- 
2.53.0


             reply	other threads:[~2026-03-24 18:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 18:08 Giovanni Cabiddu [this message]
2026-03-26  8:44 ` [PATCH] crypto: deflate - fix decompression window size Herbert Xu
2026-03-26  9:36   ` Giovanni Cabiddu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260324180905.120703-1-giovanni.cabiddu@intel.com \
    --to=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=laurent.m.coquerel@intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=qat-linux@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox