]> 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:39 +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() to avoid leaking secrets at runtime when CONFIG_DYNAMIC_DEBUG
is enabled.

Fixes: 8d818c105501 ("crypto: caam/qi2 - add DPAA2-CAAM driver")
Fixes: 226853ac3ebe ("crypto: caam/qi2 - add skcipher algorithms")
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_qi2.c

index bf10c3dda745a9266b640b8ef14706cc9e4cbd0b..6b47bcc16a5062de8e6faf547939c460169a8bea 100644 (file)
@@ -301,7 +301,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
        dev_dbg(dev, "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);
 
        ctx->adata.keylen = keys.authkeylen;
@@ -315,7 +315,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
        memcpy(ctx->key + ctx->adata.keylen_pad, keys.enckey, keys.enckeylen);
        dma_sync_single_for_device(dev, 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);
 
@@ -732,7 +732,7 @@ static int gcm_setkey(struct crypto_aead *aead,
        ret = aes_check_keylen(keylen);
        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);
@@ -828,7 +828,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);
@@ -927,7 +927,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);
@@ -955,7 +955,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);
 
        ctx->cdata.keylen = keylen;