Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: crypto4xx - Fix gcc12 uninitialized warning in crypto4xx_crypt

The compiler gcc 12 warns about the IV buffer being uninitialized
in crypto4xx_crypt. Silence the warning by using the new gcc 12
access attribute to mark crypto4xx_build_pd.

Also fix the IV buffer length as it has been quadrupled (64 instead
of 16).

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+11 -5
+2 -2
drivers/crypto/amcc/crypto4xx_alg.c
··· 72 72 { 73 73 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); 74 74 struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher); 75 - __le32 iv[AES_IV_SIZE]; 75 + __le32 iv[AES_IV_SIZE / 4]; 76 76 77 77 if (check_blocksize && !IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE)) 78 78 return -EINVAL; ··· 429 429 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); 430 430 struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req); 431 431 struct crypto_aead *aead = crypto_aead_reqtfm(req); 432 - __le32 iv[16]; 432 + __le32 iv[4]; 433 433 u32 tmp_sa[SA_AES128_CCM_LEN + 4]; 434 434 struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *)tmp_sa; 435 435 unsigned int len = req->cryptlen;
+1 -1
drivers/crypto/amcc/crypto4xx_core.c
··· 676 676 struct scatterlist *src, 677 677 struct scatterlist *dst, 678 678 const unsigned int datalen, 679 - const __le32 *iv, const u32 iv_len, 679 + const void *iv, const u32 iv_len, 680 680 const struct dynamic_sa_ctl *req_sa, 681 681 const unsigned int sa_len, 682 682 const unsigned int assoclen,
+8 -2
drivers/crypto/amcc/crypto4xx_core.h
··· 147 147 struct crypto4xx_device *dev; 148 148 }; 149 149 150 + #if IS_ENABLED(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION >= 120000 151 + #define BUILD_PD_ACCESS __attribute__((access(read_only, 6, 7))) 152 + #else 153 + #define BUILD_PD_ACCESS 154 + #endif 155 + 150 156 int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size); 151 157 void crypto4xx_free_sa(struct crypto4xx_ctx *ctx); 152 158 int crypto4xx_build_pd(struct crypto_async_request *req, ··· 160 154 struct scatterlist *src, 161 155 struct scatterlist *dst, 162 156 const unsigned int datalen, 163 - const __le32 *iv, const u32 iv_len, 157 + const void *iv, const u32 iv_len, 164 158 const struct dynamic_sa_ctl *sa, 165 159 const unsigned int sa_len, 166 160 const unsigned int assoclen, 167 - struct scatterlist *dst_tmp); 161 + struct scatterlist *dst_tmp) BUILD_PD_ACCESS; 168 162 int crypto4xx_setkey_aes_cbc(struct crypto_skcipher *cipher, 169 163 const u8 *key, unsigned int keylen); 170 164 int crypto4xx_setkey_aes_ctr(struct crypto_skcipher *cipher,