From: Herbert Xu Date: Tue, 30 Sep 2025 08:08:34 +0000 (+0800) Subject: crypto: zstd - Fix compression bug caused by truncation X-Git-Tag: v6.17.2~6 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=15ea288e1dc8ee90d9a04bb197f22599240e42c4;p=thirdparty%2Fkernel%2Fstable.git crypto: zstd - Fix compression bug caused by truncation commit 81c1a15eb4a273eabedfcc28eb6afa4b50cb8a46 upstream. 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 Fixes: f5ad93ffb541 ("crypto: zstd - convert to acomp") Signed-off-by: Herbert Xu Reviewed-by: David Sterba Tested-by: Han Xu Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- diff --git a/crypto/zstd.c b/crypto/zstd.c index c2a19cb0879d6..ac318d333b684 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)