]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: caam - use print_hex_dump_devel to guard key hex dumps
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 27 Apr 2026 16:39:37 +0000 (18:39 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 7 May 2026 08:10:02 +0000 (16:10 +0800)
Use print_hex_dump_devel() for dumping sensitive key material in
*_setkey() and gen_split_key() to avoid leaking secrets at runtime when
CONFIG_DYNAMIC_DEBUG is enabled.

Fixes: 6e005503199b ("crypto: caam - print debug messages at debug level")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/caamalg_qi.c
drivers/crypto/caam/caamhash.c
drivers/crypto/caam/key_gen.c

index 32a6e6e15ee25c617072ed0610b329334d6240df..ddbd60cf3b3c1b7cc4991853e9e9edb8e825b638 100644 (file)
@@ -603,7 +603,7 @@ static int aead_setkey(struct crypto_aead *aead,
        dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
               keys.authkeylen + keys.enckeylen, keys.enckeylen,
               keys.authkeylen);
-       print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        /*
@@ -639,7 +639,7 @@ static int aead_setkey(struct crypto_aead *aead,
        dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->adata.keylen_pad +
                                   keys.enckeylen, ctx->dir);
 
-       print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
+       print_hex_dump_devel("ctx.key@"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
                             ctx->adata.keylen_pad + keys.enckeylen, 1);
 
@@ -680,7 +680,7 @@ static int gcm_setkey(struct crypto_aead *aead,
        if (err)
                return err;
 
-       print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -701,7 +701,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
        if (err)
                return err;
 
-       print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -727,7 +727,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
        if (err)
                return err;
 
-       print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -754,7 +754,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
        u32 *desc;
        const bool is_rfc3686 = alg->caam.rfc3686;
 
-       print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        /* Here keylen is actual key length */
index 65f6adb6c673f8016533b018035b9715b6be3c64..aa779caacfe5966698e26ec628deda8276486d3a 100644 (file)
@@ -212,7 +212,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
        dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
                keys.authkeylen + keys.enckeylen, keys.enckeylen,
                keys.authkeylen);
-       print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        /*
@@ -248,7 +248,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
                                   ctx->adata.keylen_pad + keys.enckeylen,
                                   ctx->dir);
 
-       print_hex_dump_debug("ctx.key@" __stringify(__LINE__)": ",
+       print_hex_dump_devel("ctx.key@" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
                             ctx->adata.keylen_pad + keys.enckeylen, 1);
 
@@ -371,7 +371,7 @@ static int gcm_setkey(struct crypto_aead *aead,
        if (ret)
                return ret;
 
-       print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -475,7 +475,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
        if (ret)
                return ret;
 
-       print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -581,7 +581,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
        if (ret)
                return ret;
 
-       print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        memcpy(ctx->key, key, keylen);
@@ -631,7 +631,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
        const bool is_rfc3686 = alg->caam.rfc3686;
        int ret = 0;
 
-       print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
+       print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        ctx->cdata.keylen = keylen;
index ddb2a35aec2d5243b07c7da9fef42b8b0585265e..3cd71810380f65932b78ac63755a7c4157f86443 100644 (file)
@@ -505,7 +505,7 @@ static int axcbc_setkey(struct crypto_ahash *ahash, const u8 *key,
                                   DMA_TO_DEVICE);
        ctx->adata.keylen = keylen;
 
-       print_hex_dump_debug("axcbc ctx.key@" __stringify(__LINE__)" : ",
+       print_hex_dump_devel("axcbc ctx.key@" __stringify(__LINE__)" : ",
                             DUMP_PREFIX_ADDRESS, 16, 4, ctx->key, keylen, 1);
 
        return axcbc_set_sh_desc(ahash);
@@ -525,7 +525,7 @@ static int acmac_setkey(struct crypto_ahash *ahash, const u8 *key,
        ctx->adata.key_virt = key;
        ctx->adata.keylen = keylen;
 
-       print_hex_dump_debug("acmac ctx.key@" __stringify(__LINE__)" : ",
+       print_hex_dump_devel("acmac ctx.key@" __stringify(__LINE__)" : ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
 
        return acmac_set_sh_desc(ahash);
index 88cc4fe2a585df07b8cd3a9909113227b004b837..de2fcc387477dbfc6eaffe1ccb6b0b40b8f98881 100644 (file)
@@ -58,7 +58,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out,
 
        dev_dbg(jrdev, "split keylen %d split keylen padded %d\n",
                adata->keylen, adata->keylen_pad);
-       print_hex_dump_debug("ctx.key@" __stringify(__LINE__)": ",
+       print_hex_dump_devel("ctx.key@" __stringify(__LINE__)": ",
                             DUMP_PREFIX_ADDRESS, 16, 4, key_in, keylen, 1);
 
        if (local_max > max_keylen)
@@ -113,7 +113,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out,
                wait_for_completion(&result.completion);
                ret = result.err;
 
-               print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
+               print_hex_dump_devel("ctx.key@"__stringify(__LINE__)": ",
                                     DUMP_PREFIX_ADDRESS, 16, 4, key_out,
                                     adata->keylen_pad, 1);
        }