diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-08-07 17:18:37 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-09-03 23:35:03 -0400 |
commit | ebf533adc877d9171800bbce77372d8051fc35c2 (patch) | |
tree | eae178d2f083b217fd9033081e20c37cb2ffd90c /crypto | |
parent | d73d67fbcb94409e0a92952750f162d4eb696e96 (diff) |
crypto: ccm - Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this drops
AHASH_REQUEST_ON_STACK by preallocating the ahash request area combined
with the skcipher area (which are not used at the same time).
[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ccm.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/ccm.c b/crypto/ccm.c index 0a083342ec8c..b242fd0d3262 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c | |||
@@ -50,7 +50,10 @@ struct crypto_ccm_req_priv_ctx { | |||
50 | u32 flags; | 50 | u32 flags; |
51 | struct scatterlist src[3]; | 51 | struct scatterlist src[3]; |
52 | struct scatterlist dst[3]; | 52 | struct scatterlist dst[3]; |
53 | struct skcipher_request skreq; | 53 | union { |
54 | struct ahash_request ahreq; | ||
55 | struct skcipher_request skreq; | ||
56 | }; | ||
54 | }; | 57 | }; |
55 | 58 | ||
56 | struct cbcmac_tfm_ctx { | 59 | struct cbcmac_tfm_ctx { |
@@ -181,7 +184,7 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, | |||
181 | struct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req); | 184 | struct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req); |
182 | struct crypto_aead *aead = crypto_aead_reqtfm(req); | 185 | struct crypto_aead *aead = crypto_aead_reqtfm(req); |
183 | struct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead); | 186 | struct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead); |
184 | AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); | 187 | struct ahash_request *ahreq = &pctx->ahreq; |
185 | unsigned int assoclen = req->assoclen; | 188 | unsigned int assoclen = req->assoclen; |
186 | struct scatterlist sg[3]; | 189 | struct scatterlist sg[3]; |
187 | u8 *odata = pctx->odata; | 190 | u8 *odata = pctx->odata; |
@@ -427,7 +430,7 @@ static int crypto_ccm_init_tfm(struct crypto_aead *tfm) | |||
427 | crypto_aead_set_reqsize( | 430 | crypto_aead_set_reqsize( |
428 | tfm, | 431 | tfm, |
429 | align + sizeof(struct crypto_ccm_req_priv_ctx) + | 432 | align + sizeof(struct crypto_ccm_req_priv_ctx) + |
430 | crypto_skcipher_reqsize(ctr)); | 433 | max(crypto_ahash_reqsize(mac), crypto_skcipher_reqsize(ctr))); |
431 | 434 | ||
432 | return 0; | 435 | return 0; |
433 | 436 | ||