From: Herbert Xu <herbert@gondor.apana.org.au>
To: Wesley Atwell <atwellwea@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Nick Terrell <terrelln@fb.com>, David Sterba <dsterba@suse.com>,
Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>,
Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] crypto: zstd - fix segmented acomp streaming paths
Date: Mon, 4 May 2026 11:40:14 +0800 [thread overview]
Message-ID: <afgVHnFH9WCNXKvO@gondor.apana.org.au> (raw)
In-Reply-To: <20260320215124.389938-1-atwellwea@gmail.com>
On Fri, Mar 20, 2026 at 03:51:24PM -0600, Wesley Atwell wrote:
> The zstd acomp implementation does not correctly handle segmented
> source and destination walks.
>
> The compression path advances the destination walk by the full
> segment length rather than the bytes actually produced, and it only
> calls zstd_end_stream() once even though the streaming API requires it
> to be called until it returns 0. With segmented destinations this can
> leave buffered output behind and misaccount the walk progress.
>
> The decompression path has the same destination accounting issue, and
> it stops when the source walk is exhausted even if
> zstd_decompress_stream() has not yet reported that the frame is fully
> decoded and flushed. That can report success too early for segmented
> requests and incomplete frames.
>
> Fix both streaming paths by advancing destination segments by actual
> output bytes, refilling destination segments as needed, draining
> zstd_end_stream() until completion, and continuing to flush buffered
> decompression output after the source walk is exhausted. Return
> -EINVAL if decompression cannot finish once the input has been fully
> consumed.
>
> Fixes: f5ad93ffb541 ("crypto: zstd - convert to acomp")
> Assisted-by: Codex:GPT-5
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
> ---
> Changes in v2:
> - always finalize acomp walk mappings in the direct one-shot paths
> - add mapped src/dst cleanup on streaming error exits
> - reacquire a destination segment in decompression before resuming after a
> full output-chunk completion
>
> Local validation:
> - built bzImage with CONFIG_CRYPTO_SELFTESTS=y and
> CONFIG_CRYPTO_SELFTESTS_FULL=y
> - exercised segmented zstd acomp requests using temporary local testmgr
> scaffolding
> - booted under virtme and verified zstd-generic selftest passed in
> /proc/crypto
Thanks for the patch. But please redo this as a series of incremental
patches, each of which fixing a specific problem so that it is
more amenable to review.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2026-05-04 3:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 21:51 Wesley Atwell
2026-05-04 3:40 ` Herbert Xu [this message]
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=afgVHnFH9WCNXKvO@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=atwellwea@gmail.com \
--cc=davem@davemloft.net \
--cc=dsterba@suse.com \
--cc=giovanni.cabiddu@intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suman.kumar.chakraborty@intel.com \
--cc=terrelln@fb.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
all inboxes | Powered by JetHome®