diff options
author | Kees Cook <keescook@chromium.org> | 2018-09-18 22:10:55 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-09-28 00:46:08 -0400 |
commit | 888a649c1103efd891aea0f2a4e4620fb54c7484 (patch) | |
tree | 2a922914873f8793b6f3e9a1d13ce42094667bf4 | |
parent | d1e4ba83b0286b3a0888b2fd361082ecd86fd07a (diff) |
crypto: artpec6 - Remove VLA usage of skcipher
In the quest to remove all stack VLA usage from the kernel[1], this
replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage
with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
which uses a fixed stack size.
[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Lars Persson <lars.persson@axis.com>
Cc: linux-arm-kernel@axis.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Lars Persson <lars.persson@axis.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/axis/artpec6_crypto.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c index 7f07a5085e9b..e5a080e87ea8 100644 --- a/drivers/crypto/axis/artpec6_crypto.c +++ b/drivers/crypto/axis/artpec6_crypto.c | |||
@@ -330,7 +330,7 @@ struct artpec6_cryptotfm_context { | |||
330 | size_t key_length; | 330 | size_t key_length; |
331 | u32 key_md; | 331 | u32 key_md; |
332 | int crypto_type; | 332 | int crypto_type; |
333 | struct crypto_skcipher *fallback; | 333 | struct crypto_sync_skcipher *fallback; |
334 | }; | 334 | }; |
335 | 335 | ||
336 | struct artpec6_crypto_aead_hw_ctx { | 336 | struct artpec6_crypto_aead_hw_ctx { |
@@ -1199,15 +1199,15 @@ artpec6_crypto_ctr_crypt(struct skcipher_request *req, bool encrypt) | |||
1199 | pr_debug("counter %x will overflow (nblks %u), falling back\n", | 1199 | pr_debug("counter %x will overflow (nblks %u), falling back\n", |
1200 | counter, counter + nblks); | 1200 | counter, counter + nblks); |
1201 | 1201 | ||
1202 | ret = crypto_skcipher_setkey(ctx->fallback, ctx->aes_key, | 1202 | ret = crypto_sync_skcipher_setkey(ctx->fallback, ctx->aes_key, |
1203 | ctx->key_length); | 1203 | ctx->key_length); |
1204 | if (ret) | 1204 | if (ret) |
1205 | return ret; | 1205 | return ret; |
1206 | 1206 | ||
1207 | { | 1207 | { |
1208 | SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback); | 1208 | SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback); |
1209 | 1209 | ||
1210 | skcipher_request_set_tfm(subreq, ctx->fallback); | 1210 | skcipher_request_set_sync_tfm(subreq, ctx->fallback); |
1211 | skcipher_request_set_callback(subreq, req->base.flags, | 1211 | skcipher_request_set_callback(subreq, req->base.flags, |
1212 | NULL, NULL); | 1212 | NULL, NULL); |
1213 | skcipher_request_set_crypt(subreq, req->src, req->dst, | 1213 | skcipher_request_set_crypt(subreq, req->src, req->dst, |
@@ -1561,10 +1561,9 @@ static int artpec6_crypto_aes_ctr_init(struct crypto_skcipher *tfm) | |||
1561 | { | 1561 | { |
1562 | struct artpec6_cryptotfm_context *ctx = crypto_skcipher_ctx(tfm); | 1562 | struct artpec6_cryptotfm_context *ctx = crypto_skcipher_ctx(tfm); |
1563 | 1563 | ||
1564 | ctx->fallback = crypto_alloc_skcipher(crypto_tfm_alg_name(&tfm->base), | 1564 | ctx->fallback = |
1565 | 0, | 1565 | crypto_alloc_sync_skcipher(crypto_tfm_alg_name(&tfm->base), |
1566 | CRYPTO_ALG_ASYNC | | 1566 | 0, CRYPTO_ALG_NEED_FALLBACK); |
1567 | CRYPTO_ALG_NEED_FALLBACK); | ||
1568 | if (IS_ERR(ctx->fallback)) | 1567 | if (IS_ERR(ctx->fallback)) |
1569 | return PTR_ERR(ctx->fallback); | 1568 | return PTR_ERR(ctx->fallback); |
1570 | 1569 | ||
@@ -1605,7 +1604,7 @@ static void artpec6_crypto_aes_ctr_exit(struct crypto_skcipher *tfm) | |||
1605 | { | 1604 | { |
1606 | struct artpec6_cryptotfm_context *ctx = crypto_skcipher_ctx(tfm); | 1605 | struct artpec6_cryptotfm_context *ctx = crypto_skcipher_ctx(tfm); |
1607 | 1606 | ||
1608 | crypto_free_skcipher(ctx->fallback); | 1607 | crypto_free_sync_skcipher(ctx->fallback); |
1609 | artpec6_crypto_aes_exit(tfm); | 1608 | artpec6_crypto_aes_exit(tfm); |
1610 | } | 1609 | } |
1611 | 1610 | ||