mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot
@ 2024-07-03 12:49 David Gstir
  2024-07-03 17:21 ` Jarkko Sakkinen
  2024-07-12 23:55 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: David Gstir @ 2024-07-03 12:49 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Shawn Guo, Sascha Hauer,
	Fabio Estevam, Jarkko Sakkinen, David Oberhollenzer,
	Richard Weinberger
  Cc: Pengutronix Kernel Team, linux-crypto, imx, linux-arm-kernel,
	linux-kernel, sigma star Kernel Team, David Gstir,
	kernel test robot, Dan Carpenter

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.

Signed-off-by: David Gstir <david@sigma-star.at>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202405270146.Y9tPoil8-lkp@intel.com/
Fixes: 3d16af0b4cfa ("crypto: mxs-dcp: Add support for hardware-bound keys")
---
 drivers/crypto/mxs-dcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 057d73c370b7..c82775dbb557 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -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);
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot
  2024-07-03 12:49 [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot David Gstir
@ 2024-07-03 17:21 ` Jarkko Sakkinen
  2024-07-12 23:55 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2024-07-03 17:21 UTC (permalink / raw)
  To: David Gstir, Herbert Xu, David S. Miller, Shawn Guo,
	Sascha Hauer, Fabio Estevam, David Oberhollenzer,
	Richard Weinberger
  Cc: Pengutronix Kernel Team, linux-crypto, imx, linux-arm-kernel,
	linux-kernel, sigma star Kernel Team, kernel test robot,
	Dan Carpenter

On Wed Jul 3, 2024 at 3:49 PM EEST, David Gstir wrote:
> 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.
>
> Signed-off-by: David Gstir <david@sigma-star.at>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202405270146.Y9tPoil8-lkp@intel.com/
> Fixes: 3d16af0b4cfa ("crypto: mxs-dcp: Add support for hardware-bound keys")
> ---
>  drivers/crypto/mxs-dcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
> index 057d73c370b7..c82775dbb557 100644
> --- a/drivers/crypto/mxs-dcp.c
> +++ b/drivers/crypto/mxs-dcp.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot
  2024-07-03 12:49 [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot David Gstir
  2024-07-03 17:21 ` Jarkko Sakkinen
@ 2024-07-12 23:55 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-07-12 23:55 UTC (permalink / raw)
  To: David Gstir
  Cc: David S. Miller, Shawn Guo, Sascha Hauer, Fabio Estevam,
	Jarkko Sakkinen, David Oberhollenzer, Richard Weinberger,
	Pengutronix Kernel Team, linux-crypto, imx, linux-arm-kernel,
	linux-kernel, sigma star Kernel Team, kernel test robot,
	Dan Carpenter

On Wed, Jul 03, 2024 at 02:49:58PM +0200, David Gstir wrote:
> 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.
> 
> Signed-off-by: David Gstir <david@sigma-star.at>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202405270146.Y9tPoil8-lkp@intel.com/
> 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.
-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-12 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-03 12:49 [PATCH] crypto: mxs-dcp: Ensure payload is zero when using key slot David Gstir
2024-07-03 17:21 ` Jarkko Sakkinen
2024-07-12 23:55 ` Herbert Xu

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®