Skip to content

Commit cdbde4c

Browse files
atenartgregkh
authored andcommitted
crypto: inside-secure - fix request allocations in invalidation path
[ Upstream commit 7cad2fa ] 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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7cc6e84 commit cdbde4c

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
@@ -470,25 +470,25 @@ static int safexcel_ahash_exit_inv(struct crypto_tfm *tfm)
470470
{
471471
struct safexcel_ahash_ctx *ctx = crypto_tfm_ctx(tfm);
472472
struct safexcel_crypto_priv *priv = ctx->priv;
473-
struct ahash_request req;
474-
struct safexcel_ahash_req *rctx = ahash_request_ctx(&req);
473+
AHASH_REQUEST_ON_STACK(req, __crypto_ahash_cast(tfm));
474+
struct safexcel_ahash_req *rctx = ahash_request_ctx(req);
475475
struct safexcel_inv_result result = {};
476476
int ring = ctx->base.ring;
477477

478-
memset(&req, 0, sizeof(struct ahash_request));
478+
memset(req, 0, sizeof(struct ahash_request));
479479

480480
/* create invalidation request */
481481
init_completion(&result.completion);
482-
ahash_request_set_callback(&req, CRYPTO_TFM_REQ_MAY_BACKLOG,
482+
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
483483
safexcel_inv_complete, &result);
484484

485-
ahash_request_set_tfm(&req, __crypto_ahash_cast(tfm));
486-
ctx = crypto_tfm_ctx(req.base.tfm);
485+
ahash_request_set_tfm(req, __crypto_ahash_cast(tfm));
486+
ctx = crypto_tfm_ctx(req->base.tfm);
487487
ctx->base.exit_inv = true;
488488
rctx->needs_inv = true;
489489

490490
spin_lock_bh(&priv->ring[ring].queue_lock);
491-
crypto_enqueue_request(&priv->ring[ring].queue, &req.base);
491+
crypto_enqueue_request(&priv->ring[ring].queue, &req->base);
492492
spin_unlock_bh(&priv->ring[ring].queue_lock);
493493

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

0 commit comments

Comments
 (0)