Skip to content

Commit 7cad2fa

Browse files
atenartherbertx
authored andcommitted
crypto: inside-secure - fix request allocations in invalidation path
This patch makes use of the SKCIPHER_REQUEST_ON_STACK and AHASH_REQUEST_ON_STACK helpers to allocate enough memory to contain both the crypto request structures and their embedded context (__ctx). Fixes: 1b44c5a ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver") Suggested-by: Ofer Heifetz <oferh@marvell.com> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 0a02dcc commit 7cad2fa

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎drivers/crypto/inside-secure/safexcel_cipher.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,25 +422,25 @@ static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm)
422422
{
423423
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
424424
struct safexcel_crypto_priv *priv = ctx->priv;
425-
struct skcipher_request req;
426-
struct safexcel_cipher_req *sreq = skcipher_request_ctx(&req);
425+
SKCIPHER_REQUEST_ON_STACK(req, __crypto_skcipher_cast(tfm));
426+
struct safexcel_cipher_req *sreq = skcipher_request_ctx(req);
427427
struct safexcel_inv_result result = {};
428428
int ring = ctx->base.ring;
429429

430-
memset(&req, 0, sizeof(struct skcipher_request));
430+
memset(req, 0, sizeof(struct skcipher_request));
431431

432432
/* create invalidation request */
433433
init_completion(&result.completion);
434-
skcipher_request_set_callback(&req, CRYPTO_TFM_REQ_MAY_BACKLOG,
435-
safexcel_inv_complete, &result);
434+
skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
435+
safexcel_inv_complete, &result);
436436

437-
skcipher_request_set_tfm(&req, __crypto_skcipher_cast(tfm));
438-
ctx = crypto_tfm_ctx(req.base.tfm);
437+
skcipher_request_set_tfm(req, __crypto_skcipher_cast(tfm));
438+
ctx = crypto_tfm_ctx(req->base.tfm);
439439
ctx->base.exit_inv = true;
440440
sreq->needs_inv = true;
441441

442442
spin_lock_bh(&priv->ring[ring].queue_lock);
443-
crypto_enqueue_request(&priv->ring[ring].queue, &req.base);
443+
crypto_enqueue_request(&priv->ring[ring].queue, &req->base);
444444
spin_unlock_bh(&priv->ring[ring].queue_lock);
445445

446446
if (!priv->ring[ring].need_dequeue)

‎drivers/crypto/inside-secure/safexcel_hash.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,25 +450,25 @@ static int safexcel_ahash_exit_inv(struct crypto_tfm *tfm)
450450
{
451451
struct safexcel_ahash_ctx *ctx = crypto_tfm_ctx(tfm);
452452
struct safexcel_crypto_priv *priv = ctx->priv;
453-
struct ahash_request req;
454-
struct safexcel_ahash_req *rctx = ahash_request_ctx(&req);
453+
AHASH_REQUEST_ON_STACK(req, __crypto_ahash_cast(tfm));
454+
struct safexcel_ahash_req *rctx = ahash_request_ctx(req);
455455
struct safexcel_inv_result result = {};
456456
int ring = ctx->base.ring;
457457

458-
memset(&req, 0, sizeof(struct ahash_request));
458+
memset(req, 0, sizeof(struct ahash_request));
459459

460460
/* create invalidation request */
461461
init_completion(&result.completion);
462-
ahash_request_set_callback(&req, CRYPTO_TFM_REQ_MAY_BACKLOG,
462+
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
463463
safexcel_inv_complete, &result);
464464

465-
ahash_request_set_tfm(&req, __crypto_ahash_cast(tfm));
466-
ctx = crypto_tfm_ctx(req.base.tfm);
465+
ahash_request_set_tfm(req, __crypto_ahash_cast(tfm));
466+
ctx = crypto_tfm_ctx(req->base.tfm);
467467
ctx->base.exit_inv = true;
468468
rctx->needs_inv = true;
469469

470470
spin_lock_bh(&priv->ring[ring].queue_lock);
471-
crypto_enqueue_request(&priv->ring[ring].queue, &req.base);
471+
crypto_enqueue_request(&priv->ring[ring].queue, &req->base);
472472
spin_unlock_bh(&priv->ring[ring].queue_lock);
473473

474474
if (!priv->ring[ring].need_dequeue)

0 commit comments

Comments
 (0)