kernel: bump 4.14 to 4.14.114
[openwrt/openwrt.git] / target / linux / apm821xx / patches-4.14 / 022-0004-crypto-crypto4xx-avoid-VLA-use.patch
1 From c4e90650ff0cbf123ec9cfc32026fa0fb2931658 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Thu, 19 Apr 2018 18:41:53 +0200
4 Subject: [PATCH 4/8] crypto: crypto4xx - avoid VLA use
5
6 This patch fixes some of the -Wvla warnings.
7
8 crypto4xx_alg.c:83:19: warning: Variable length array is used.
9 crypto4xx_alg.c:273:56: warning: Variable length array is used.
10 crypto4xx_alg.c:380:32: warning: Variable length array is used.
11
12 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
13 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
14 ---
15 drivers/crypto/amcc/crypto4xx_alg.c | 14 ++++----------
16 1 file changed, 4 insertions(+), 10 deletions(-)
17
18 --- a/drivers/crypto/amcc/crypto4xx_alg.c
19 +++ b/drivers/crypto/amcc/crypto4xx_alg.c
20 @@ -80,7 +80,7 @@ static inline int crypto4xx_crypt(struct
21 {
22 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
23 struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
24 - __le32 iv[ivlen];
25 + __le32 iv[AES_IV_SIZE];
26
27 if (ivlen)
28 crypto4xx_memcpy_to_le32(iv, req->iv, ivlen);
29 @@ -271,13 +271,7 @@ static inline bool crypto4xx_aead_need_f
30 static int crypto4xx_aead_fallback(struct aead_request *req,
31 struct crypto4xx_ctx *ctx, bool do_decrypt)
32 {
33 - char aead_req_data[sizeof(struct aead_request) +
34 - crypto_aead_reqsize(ctx->sw_cipher.aead)]
35 - __aligned(__alignof__(struct aead_request));
36 -
37 - struct aead_request *subreq = (void *) aead_req_data;
38 -
39 - memset(subreq, 0, sizeof(aead_req_data));
40 + struct aead_request *subreq = aead_request_ctx(req);
41
42 aead_request_set_tfm(subreq, ctx->sw_cipher.aead);
43 aead_request_set_callback(subreq, req->base.flags,
44 @@ -378,7 +372,7 @@ static int crypto4xx_crypt_aes_ccm(struc
45 struct crypto_aead *aead = crypto_aead_reqtfm(req);
46 unsigned int len = req->cryptlen;
47 __le32 iv[16];
48 - u32 tmp_sa[ctx->sa_len * 4];
49 + u32 tmp_sa[SA_AES128_CCM_LEN + 4];
50 struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *)tmp_sa;
51
52 if (crypto4xx_aead_need_fallback(req, true, decrypt))
53 @@ -387,7 +381,7 @@ static int crypto4xx_crypt_aes_ccm(struc
54 if (decrypt)
55 len -= crypto_aead_authsize(aead);
56
57 - memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, sizeof(tmp_sa));
58 + memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, ctx->sa_len * 4);
59 sa->sa_command_0.bf.digest_len = crypto_aead_authsize(aead) >> 2;
60
61 if (req->iv[0] == 1) {