From: Herbert Xu <herbert@gondor.apana.org.au>
To: Han Xu <han.xu@nxp.com>
Cc: "suman.kumar.chakraborty@intel.com"
<suman.kumar.chakraborty@intel.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"terrelln@fb.com" <terrelln@fb.com>,
"dsterba@suse.com" <dsterba@suse.com>,
Richard Weinberger <richard@nod.at>,
"chengzhihao1@huawei.com" <chengzhihao1@huawei.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:MEMORY TECHNOLOGY DEVICES (MTD)"
<linux-mtd@lists.infradead.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>
Subject: [PATCH] crypto: zstd - Fix compression bug caused by truncation
Date: Tue, 30 Sep 2025 16:08:34 +0800 [thread overview]
Message-ID: <aNuQAr79Hdky3WII@gondor.apana.org.au> (raw)
In-Reply-To: <GV1PR04MB9071B5AC95DBD48B67FACF44971BA@GV1PR04MB9071.eurprd04.prod.outlook.com>
On Mon, Sep 29, 2025 at 11:51:36PM +0000, Han Xu wrote:
> Hi Suman,
>
> The patch f5ad93ffb5411 "crypto: zstd - convert to acomp"
> leads to the following kernel dump during UBIFS write back.
Thanks for the detailed report and instructions!
Please let me know if you still get the crash with this patch:
---8<---
Use size_t for the return value of zstd_compress_cctx as otherwise
negative errors will be truncated to a positive value.
Reported-by: Han Xu <han.xu@nxp.com>
Fixes: f5ad93ffb541 ("crypto: zstd - convert to acomp")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/crypto/zstd.c b/crypto/zstd.c
index c2a19cb0879d..ac318d333b68 100644
--- a/crypto/zstd.c
+++ b/crypto/zstd.c
@@ -83,7 +83,7 @@ static void zstd_exit(struct crypto_acomp *acomp_tfm)
static int zstd_compress_one(struct acomp_req *req, struct zstd_ctx *ctx,
const void *src, void *dst, unsigned int *dlen)
{
- unsigned int out_len;
+ size_t out_len;
ctx->cctx = zstd_init_cctx(ctx->wksp, ctx->wksp_size);
if (!ctx->cctx)
--
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-09-30 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 23:51 [Bug report] crypto: zstd: kernel dump during UBIFS write back Han Xu
2025-09-30 8:08 ` Herbert Xu [this message]
2025-09-30 8:34 ` [PATCH] crypto: zstd - Fix compression bug caused by truncation Suman Kumar Chakraborty
2025-09-30 13:32 ` David Sterba
2025-09-30 16:09 ` Han 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=aNuQAr79Hdky3WII@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=chengzhihao1@huawei.com \
--cc=davem@davemloft.net \
--cc=dsterba@suse.com \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--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