mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Fang Xieyan <fangxy@xiaopeng.com>
Cc: davem@davemloft.net, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] crypto: scomp - Bound the single-page source scratch buffer
Date: Fri, 4 Dec 2026 13:43:37 +0800	[thread overview]
Message-ID: <axJTCfxGcivTc4m2@gondor.apana.org.au> (raw)
In-Reply-To: <20261128145056.78807-1-fangxy@xiaopeng.com>

Fang Xieyan <fangxy@xiaopeng.com> wrote:
>
> diff --git a/crypto/scompress.c b/crypto/scompress.c
> index de54227203ce..02438d8f1751 100644
> --- a/crypto/scompress.c
> +++ b/crypto/scompress.c
> @@ -232,8 +232,16 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>        struct crypto_acomp_stream *stream = crypto_acomp_lock_stream_bh(&crypto_scomp_alg(scomp)->streams);
> 
>        if (!src_isvirt && !src) {
> -               struct scomp_scratch *scratch = scomp_lock_scratch();
> -               const u8 *src = scratch->src;
> +               struct scomp_scratch *scratch;
> +               const u8 *src;
> +
> +               if (slen > PAGE_SIZE) {
> +                       ret = -EINVAL;
> +                       goto out;
> +               }
> +
> +               scratch = scomp_lock_scratch();
> +               src = scratch->src;
> 
>                memcpy_from_sglist(scratch->src, req->src, 0, slen);

Good catch!

But the contract is that all callers should have slen <= PAGE_SIZE.

So please express that at the top of the function:

	if (!req->src || !slen)
		return -EINVAL;

	if (slen > PAGE_SIZE)
		return -ENOSYS;

BTW, did you identify any callers with either virt or SG sources
greater than PAGE_SIZE when performing decompression?

Thanks,
-- 
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

      reply	other threads:[~2026-12-04  5:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 14:50 Fang Xieyan
2026-12-04  5:43 ` 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=axJTCfxGcivTc4m2@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=fangxy@xiaopeng.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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®