Skip to contentSkip to conversation

crypto: mxs-dcp: Ensure payload is zero when using key slot

PATCH In review David Gstir 3 participants 3 messages Jul 3, 2024 – Jul 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: mxs-dcp: Ensure payload is zero when using key slot

We could leak stack memory through the payload field when running AES with a key from one of the hardware's key slots. Fix this by ensuring the payload field is set to 0 in such cases.

This does not affect the common use case when the key is supplied from main memory via the descriptor payload.

Fixes 3d16af0b4cfa ("crypto: mxs-dcp: Add support for hardware-bound keys")
---
 drivers/crypto/mxs-dcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/mxs-dcp.c +2 -1
index 057d73c370b7..c82775dbb557 100644
@@ -225,7 +225,8 @@ static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
 static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
 			   struct skcipher_request *req, int init)
 {
-	dma_addr_t key_phys, src_phys, dst_phys;
+	dma_addr_t key_phys = 0;
+	dma_addr_t src_phys, dst_phys;
 	struct dcp *sdcp = global_sdcp;
 	struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
 	struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);
Signature · 1 line
2.35.3
#1 lore raw
Quoted 21 lines · David Gstir

We could leak stack memory through the payload field when running AES with a key from one of the hardware's key slots. Fix this by ensuring the payload field is set to 0 in such cases.

This does not affect the common use case when the key is supplied from main memory via the descriptor payload.

Fixes 3d16af0b4cfa ("crypto: mxs-dcp: Add support for hardware-bound keys")
---
 drivers/crypto/mxs-dcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/mxs-dcp.c +0 -0
index 057d73c370b7..c82775dbb557 100644

drivers/crypto/mxs-dcp.c static int mxs_dcp_start_dma(struct dcp_async_ctx *actx) · line 232

Quoted 9 lines
drivers/crypto/mxs-dcp.c +2 -1
@@ -225,7 +225,8 @@ static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
 static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
 			   struct skcipher_request *req, int init)
 {
-	dma_addr_t key_phys, src_phys, dst_phys;
+	dma_addr_t key_phys = 0;
+	dma_addr_t src_phys, dst_phys;
 	struct dcp *sdcp = global_sdcp;
 	struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
 	struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);

I'm on holiday up until week 31 so might be that review will take up to then.

BR, Jarkko

maintainer
#2 lore raw
In reply to David Gstir
Quoted 7 lines · David Gstir

We could leak stack memory through the payload field when running AES with a key from one of the hardware's key slots. Fix this by ensuring the payload field is set to 0 in such cases.

This does not affect the common use case when the key is supplied from main memory via the descriptor payload.

Quoted 8 lines
Fixes 3d16af0b4cfa ("crypto: mxs-dcp: Add support for hardware-bound keys")
---
 drivers/crypto/mxs-dcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt