crypto: crypto4xx - Fix gcc12 uninitialized warning in crypto4xx_crypt
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 19 Mar 2025 09:26:43 +0000 (17:26 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 7 Apr 2025 05:22:25 +0000 (13:22 +0800)
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>
drivers/crypto/amcc/crypto4xx_alg.c
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/amcc/crypto4xx_core.h

index e0af611a95d88f89da3b2cde4bac06f6886c92ab..289750f34ccf09fd4e71c1755564402b43d0a3b5 100644 (file)
@@ -72,7 +72,7 @@ static inline int crypto4xx_crypt(struct skcipher_request *req,
 {
        struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
        struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
-       __le32 iv[AES_IV_SIZE];
+       __le32 iv[AES_IV_SIZE / 4];
 
        if (check_blocksize && !IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE))
                return -EINVAL;
@@ -429,7 +429,7 @@ static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt)
        struct crypto4xx_ctx *ctx  = crypto_tfm_ctx(req->base.tfm);
        struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req);
        struct crypto_aead *aead = crypto_aead_reqtfm(req);
-       __le32 iv[16];
+       __le32 iv[4];
        u32 tmp_sa[SA_AES128_CCM_LEN + 4];
        struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *)tmp_sa;
        unsigned int len = req->cryptlen;
index ec3ccfa60445fcb9dbbe3f0de60bec4ab35f9574..c77d06ddb1ec816e23cd9db1fe9c77a52c211b48 100644 (file)
@@ -676,7 +676,7 @@ int crypto4xx_build_pd(struct crypto_async_request *req,
                       struct scatterlist *src,
                       struct scatterlist *dst,
                       const unsigned int datalen,
-                      const __le32 *iv, const u32 iv_len,
+                      const void *iv, const u32 iv_len,
                       const struct dynamic_sa_ctl *req_sa,
                       const unsigned int sa_len,
                       const unsigned int assoclen,
index 3adcc5e65694214785f4f063f949cffb6d3a3293..9c56c7ac6e4c67e980e14f25de0a58d002dce2da 100644 (file)
@@ -147,6 +147,12 @@ struct crypto4xx_alg {
        struct crypto4xx_device *dev;
 };
 
+#if IS_ENABLED(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION >= 120000
+#define BUILD_PD_ACCESS __attribute__((access(read_only, 6, 7)))
+#else
+#define BUILD_PD_ACCESS
+#endif
+
 int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size);
 void crypto4xx_free_sa(struct crypto4xx_ctx *ctx);
 int crypto4xx_build_pd(struct crypto_async_request *req,
@@ -154,11 +160,11 @@ int crypto4xx_build_pd(struct crypto_async_request *req,
                       struct scatterlist *src,
                       struct scatterlist *dst,
                       const unsigned int datalen,
-                      const __le32 *iv, const u32 iv_len,
+                      const void *iv, const u32 iv_len,
                       const struct dynamic_sa_ctl *sa,
                       const unsigned int sa_len,
                       const unsigned int assoclen,
-                      struct scatterlist *dst_tmp);
+                      struct scatterlist *dst_tmp) BUILD_PD_ACCESS;
 int crypto4xx_setkey_aes_cbc(struct crypto_skcipher *cipher,
                             const u8 *key, unsigned int keylen);
 int crypto4xx_setkey_aes_ctr(struct crypto_skcipher *cipher,