public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: <linux-crypto@vger.kernel.org>, <qat-linux@intel.com>,
	Laurent M Coquerel <laurent.m.coquerel@intel.com>
Subject: Re: [PATCH v2] crypto: deflate - fix decompression window size
Date: Thu, 16 Apr 2026 18:03:59 +0100	[thread overview]
Message-ID: <aeEWf4j+VO0FziNj@gcabiddu-mobl.ger.corp.intel.com> (raw)
In-Reply-To: <ac8I4mpkdn8uy8TE@gondor.apana.org.au>

Hi Herbert,

On Fri, Apr 03, 2026 at 08:25:06AM +0800, Herbert Xu wrote:
> On Thu, Mar 26, 2026 at 09:59:22AM +0000, Giovanni Cabiddu wrote:
> > 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).
> > 
> > Data compressed with a history window larger than 2 KB, for example
> > produced by hardware compressors such as QAT or IAA, might not be
> > decompressed by deflate-generic since the inflate stream is initialized
> > with a 2 KB window. This might be seen, for example, when
> > deflate-generic is used as fallback.
> > 
> > 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: f6ded09de8bd ("crypto: acomp - add support for deflate via scomp")
> > Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> > Reviewed-by: Laurent M Coquerel <laurent.m.coquerel@intel.com>
> > ---
> > Changes since v1:
> > - Updated commit message to clearly state why this is needed for the
> >   deflate algorithm (i.e. allow data produced by HW compressors with
> >   larger history windows to be decompressed by deflate-generic, which
> >   is used as fallback).
> > - Updated fixes tag to point to the commit that introduced deflate
> >   support in scomp.
> > 
> >  crypto/deflate.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> What happened to the parameters patch-set?
I'm reworking the acomp/BTRFS set, and that will be included there.

> Wouldn't this be something that should be treated as a parameter?
I don't think this should be treated as a parameter. A decompressor must
be able to handle any valid DEFLATE stream. RFC1951 (section 3.3) [1]
states that while a compressor may restrict parameters such as window
size, a compliant decompressor must accept the full range defined by the
specification.

In this case, deflate-generic does not accept valid streams compressed
with the full 32KB history window, which is why I proposed this change.

[1] https://datatracker.ietf.org/doc/html/rfc1951

Regards,

-- 
Giovanni

  reply	other threads:[~2026-04-16 17:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26  9:59 [PATCH v2] crypto: deflate - fix decompression window size Giovanni Cabiddu
2026-04-03  0:25 ` Herbert Xu
2026-04-16 17:03   ` Giovanni Cabiddu [this message]
2026-04-20  8:50     ` Herbert Xu
2026-04-20 10:37       ` Giovanni Cabiddu
2026-04-21  3:01         ` Herbert Xu

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=aeEWf4j+VO0FziNj@gcabiddu-mobl.ger.corp.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