From: Antoine Tenart <atenart@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Aleksander Jan Bajkowski <olek2@wp.pl>,
Pascal van Leeuwen <pvanleeuwen@insidesecure.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 07/10] crypto: safexcel - Check scatterlist errors before max() for in-place
Date: Thu, 26 Nov 2026 17:47:15 +0100 [thread overview]
Message-ID: <awhiMq5yUzdssptB@toolbx> (raw)
In-Reply-To: <20261123151055.2533735-8-lee@kernel.org>
On Mon, Nov 23, 2026 at 03:09:58PM +0000, Lee Jones wrote:
> In safexcel_send_req(), sg_nents_for_len() returns -EINVAL when a
> scatterlist is shorter than the required payload length. For in-place
> requests (src == dst), the driver combines sreq->nr_src and
> sreq->nr_dst using max() before checking for errors.
>
> When an in-place AEAD encryption request provides a scatterlist large
> enough for totlen_src (sreq->nr_src > 0) but too short for the
> appended authentication tag in totlen_dst (sreq->nr_dst == -EINVAL),
> max() selects the positive sreq->nr_src and discards -EINVAL. The
> driver then maps only the undersized buffer while programming the
> engine token to emit totlen_dst bytes.
>
> Check both sreq->nr_src and sreq->nr_dst for negative error values
> before combining them with max().
>
> Fixes: 19b347b32bb1 ("crypto: inside-secure - fix scatter/gather list to descriptor conversion")
> Closes: https://sashiko.dev/#/bug/linux-78f87af5-af5e-439c-bb52-de4c8c53fdee
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
> ---
> drivers/crypto/inside-secure/safexcel_cipher.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
> index b031cb9652ec..e7816f6ddeaa 100644
> --- a/drivers/crypto/inside-secure/safexcel_cipher.c
> +++ b/drivers/crypto/inside-secure/safexcel_cipher.c
> @@ -736,14 +736,13 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
> queued = totlen_src;
>
> if (src == dst) {
> - sreq->nr_src = max(sreq->nr_src, sreq->nr_dst);
> - sreq->nr_dst = sreq->nr_src;
> - if (unlikely((totlen_src || totlen_dst) &&
> - (sreq->nr_src <= 0))) {
> + if (unlikely(sreq->nr_src < 0 || sreq->nr_dst < 0)) {
> dev_err(priv->dev, "In-place buffer not large enough (need %d bytes)!",
> max(totlen_src, totlen_dst));
> return -EINVAL;
> }
> + sreq->nr_src = max(sreq->nr_src, sreq->nr_dst);
> + sreq->nr_dst = sreq->nr_src;
> if (sreq->nr_src > 0 &&
> !dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL))
> return -EIO;
> --
> 2.56.1.750.gf70dc682cf-goog
>
next prev parent reply other threads:[~2026-11-26 16:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:09 [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers Lee Jones
2026-11-23 15:09 ` [PATCH 01/10] crypto: caam - Fix descriptor buffer overflow in caam_process_blob() Lee Jones
2026-11-23 15:09 ` [PATCH 02/10] crypto: marvell - Fix AEAD key buffer overflow for SHA-384/512 HMAC Lee Jones
2026-11-23 15:09 ` [PATCH 03/10] crypto: nx - Fix bounce buffer copy overflow in decompress() Lee Jones
2026-11-23 15:09 ` [PATCH 04/10] crypto: sun8i-ss - Fix scatterlist array overflow for HMAC requests Lee Jones
2026-11-23 15:09 ` [PATCH 05/10] crypto: hisilicon/hpre - Fix buffer overflow on odd ECDH input size Lee Jones
2026-11-24 7:39 ` liulongfang
2026-11-23 15:09 ` [PATCH 06/10] crypto: talitos - Remove duplicate IV unmap in AEAD encrypt path Lee Jones
2026-11-23 15:09 ` [PATCH 07/10] crypto: safexcel - Check scatterlist errors before max() for in-place Lee Jones
2026-11-26 16:47 ` Antoine Tenart [this message]
2026-11-23 15:09 ` [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs() Lee Jones
2026-11-24 12:49 ` Bartosz Golaszewski
2026-11-23 15:10 ` [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails Lee Jones
2026-11-24 12:49 ` Bartosz Golaszewski
2026-11-23 15:10 ` [PATCH 10/10] crypto: atmel-tdes - Update output IV before clearing busy flag Lee Jones
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=awhiMq5yUzdssptB@toolbx \
--to=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=lee@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olek2@wp.pl \
--cc=pvanleeuwen@insidesecure.com \
--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