mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
crypto: caam - use print_hex_dump_devel to guard key hex dumps
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: 6e00550319 ("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>
This commit is contained in:
committed by
Herbert Xu
parent
319400fc5e
commit
3f57657b6e
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user