* [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers
@ 2026-11-23 15:09 Lee Jones
2026-11-23 15:09 ` [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs() Lee Jones
2026-11-23 15:10 ` [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Lee Jones @ 2026-11-23 15:09 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
Horia Geantă, Ritesh Harjani (IBM), Aleksander Jan Bajkowski,
Alexandre Belloni, Antoine Tenart, Bartosz Golaszewski,
Bharat Bhushan, bui duc phuc, Bulent Abali, Chen-Yu Tsai,
Claudiu Beznea, Corentin Labbe, Dan Streetman, Evgeniy Polyakov,
Haren Myneni, Herbert Xu, Jernej Skrabec, Kim Phillips,
linux-arm-kernel, linux-arm-msm, linux-crypto, linux-sunxi,
linuxppc-dev, Longfang Liu, Madhavan Srinivasan,
Meenakshi Aggarwal, Meng Yu, Michael Ellerman, Nicholas Piggin,
Nicolas Ferre, Nicolas Royer, Pankaj Gupta, Pascal van Leeuwen,
Paul Louvel, Robert Jennings, Sahil Malhotra, Samuel Holland,
Seth Jennings, Shrikanth Hegde, Srujana Challa, Stanimir Varbanov,
Steffen Trumtrar, Thorsten Blum, Tudor Ambarus, Weili Qian,
Zaibo Xu, Zhiqi Song
These issues were reported by Sashiko.
None of these changes have been tested on physical hardware.
Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Horia Geantă" <horia.geanta@nxp.com>
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Aleksander Jan Bajkowski <olek2@wp.pl>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Antoine Tenart <atenart@kernel.org>
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Bharat Bhushan <bbhushan2@marvell.com>
Cc: bui duc phuc <phucduc.bui@gmail.com>
Cc: Bulent Abali <abali@us.ibm.com>
Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Corentin Labbe <clabbe.montjoie@gmail.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Haren Myneni <haren@us.ibm.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Kim Phillips <kim.phillips@freescale.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-crypto@vger.kernel.org
Cc: linux-sunxi@lists.linux.dev
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Longfang Liu <liulongfang@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Cc: Meng Yu <yumeng18@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Nicolas Royer <nicolas@eukrea.com>
Cc: Pankaj Gupta <pankaj.gupta@nxp.com>
Cc: Pascal van Leeuwen <pvanleeuwen@insidesecure.com>
Cc: Paul Louvel <paul.louvel@bootlin.com>
Cc: Robert Jennings <rcj@linux.vnet.ibm.com>
Cc: Sahil Malhotra <sahil.malhotra@nxp.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Srujana Challa <schalla@marvell.com>
Cc: Stanimir Varbanov <svarbanov@mm-sol.com>
Cc: Steffen Trumtrar <kernel@pengutronix.de>
Cc: Thorsten Blum <blum@kernel.org>
Cc: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Weili Qian <qianweili@huawei.com>
Cc: Zaibo Xu <xuzaibo@huawei.com>
Cc: Zhiqi Song <songzhiqi1@huawei.com>
Lee Jones (10):
crypto: caam - Fix descriptor buffer overflow in caam_process_blob()
crypto: marvell - Fix AEAD key buffer overflow for SHA-384/512 HMAC
crypto: nx - Fix bounce buffer copy overflow in decompress()
crypto: sun8i-ss - Fix scatterlist array overflow for HMAC requests
crypto: hisilicon/hpre - Fix buffer overflow on odd ECDH input size
crypto: talitos - Remove duplicate IV unmap in AEAD encrypt path
crypto: safexcel - Check scatterlist errors before max() for in-place
crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs()
crypto: qce - Terminate RX DMA channel if TX preparation fails
crypto: atmel-tdes - Update output IV before clearing busy flag
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 7 +++++--
drivers/crypto/atmel-tdes.c | 7 +++++--
drivers/crypto/caam/blob_gen.c | 12 ++++++++----
drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 +++--
drivers/crypto/inside-secure/safexcel_cipher.c | 7 +++----
drivers/crypto/marvell/octeontx/otx_cptvf_algs.h | 2 +-
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h | 2 +-
drivers/crypto/nx/nx-842.c | 5 ++++-
drivers/crypto/qce/dma.c | 8 ++++++--
drivers/crypto/qce/sha.c | 9 +++++----
drivers/crypto/talitos.c | 4 ----
11 files changed, 41 insertions(+), 27 deletions(-)
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs()
2026-11-23 15:09 [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers Lee Jones
@ 2026-11-23 15:09 ` Lee Jones
2026-11-23 15:10 ` [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2026-11-23 15:09 UTC (permalink / raw)
To: lee, Bartosz Golaszewski, Herbert Xu, David S. Miller,
Thorsten Blum, Stanimir Varbanov, linux-crypto, linux-arm-msm,
linux-kernel
Cc: stable
In qce_ahash_async_req_handle(), dma_map_sg() maps req->src and returns
the number of coalesced DMA segments in ret, which is immediately
overwritten when mapping rctx->result_sg. The function then passes the
unmapped segment count rctx->src_nents to qce_dma_prep_sgs().
When an IOMMU coalesces scatterlist entries so the mapped count is
smaller than rctx->src_nents, dmaengine_prep_slave_sg() walks past the
mapped entries and reads uninitialised DMA addresses and lengths from
the tail of req->src, while dma_unmap_sg() still requires the original
rctx->src_nents count.
Save the mapped segment count from dma_map_sg() in a dedicated
src_nents variable and pass it to qce_dma_prep_sgs(), matching the
skcipher path.
Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
Closes: https://sashiko.dev/#/bug/linux-24490c31-257a-4148-a816-0aaf416f64a1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/crypto/qce/sha.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
index b67d749db05f..56106f415db6 100644
--- a/drivers/crypto/qce/sha.c
+++ b/drivers/crypto/qce/sha.c
@@ -77,7 +77,7 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req)
struct qce_alg_template *tmpl = to_ahash_tmpl(async_req->tfm);
struct qce_device *qce = tmpl->qce;
unsigned long flags = rctx->flags;
- int ret;
+ int ret, src_nents;
if (IS_SHA_HMAC(flags)) {
rctx->authkey = ctx->authkey;
@@ -93,8 +93,9 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req)
return rctx->src_nents;
}
- ret = dma_map_sg(qce->dev, req->src, rctx->src_nents, DMA_TO_DEVICE);
- if (!ret)
+ src_nents = dma_map_sg(qce->dev, req->src, rctx->src_nents,
+ DMA_TO_DEVICE);
+ if (!src_nents)
return -EIO;
sg_init_one(&rctx->result_sg, qce->dma.result_buf, QCE_RESULT_BUF_SZ);
@@ -105,7 +106,7 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req)
goto error_unmap_src;
}
- ret = qce_dma_prep_sgs(&qce->dma, req->src, rctx->src_nents,
+ ret = qce_dma_prep_sgs(&qce->dma, req->src, src_nents,
&rctx->result_sg, 1, qce_ahash_done, async_req);
if (ret)
goto error_unmap_dst;
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails
2026-11-23 15:09 [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers Lee Jones
2026-11-23 15:09 ` [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs() Lee Jones
@ 2026-11-23 15:10 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2026-11-23 15:10 UTC (permalink / raw)
To: lee, Bartosz Golaszewski, Herbert Xu, David S. Miller,
Stanimir Varbanov, linux-crypto, linux-arm-msm, linux-kernel
Cc: stable
qce_dma_prep_sgs() prepares and submits the rxchan DMA descriptor via
qce_dma_prep_sg() before preparing the txchan descriptor. If the
subsequent txchan preparation fails, qce_dma_prep_sgs() returns an
error while leaving the submitted rxchan descriptor queued in the DMA
engine, and callers jump straight to unmapping their scatterlists
without calling qce_dma_terminate_all().
On the next cryptographic request, qce_dma_issue_pending() flushes the
stale rxchan descriptor against already-unmapped memory.
Terminate rxchan via dmaengine_terminate_async() when preparing txchan
fails in qce_dma_prep_sgs().
Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
Closes: https://sashiko.dev/#/bug/linux-0b5dbd9f-7869-4856-a8e5-47c2c6e342f1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/crypto/qce/dma.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
index 68cafd4741ad..726e7fd3421e 100644
--- a/drivers/crypto/qce/dma.c
+++ b/drivers/crypto/qce/dma.c
@@ -116,8 +116,12 @@ int qce_dma_prep_sgs(struct qce_dma_data *dma, struct scatterlist *rx_sg,
if (ret)
return ret;
- return qce_dma_prep_sg(txchan, tx_sg, tx_nents, flags, DMA_DEV_TO_MEM,
- cb, cb_param);
+ ret = qce_dma_prep_sg(txchan, tx_sg, tx_nents, flags, DMA_DEV_TO_MEM,
+ cb, cb_param);
+ if (ret)
+ dmaengine_terminate_async(rxchan);
+
+ return ret;
}
void qce_dma_issue_pending(struct qce_dma_data *dma)
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 15:09 [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers Lee Jones
2026-11-23 15:09 ` [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs() Lee Jones
2026-11-23 15:10 ` [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox