Skip to content

Commit 9a53dc0

Browse files
tobluxgregkh
authored andcommitted
crypto: caam - use print_hex_dump_devel to guard key hex dumps
commit 3f57657 upstream. 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: 6e00550 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a22cb6b commit 9a53dc0

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

drivers/crypto/caam/caamalg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static int aead_setkey(struct crypto_aead *aead,
588588
dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
589589
keys.authkeylen + keys.enckeylen, keys.enckeylen,
590590
keys.authkeylen);
591-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
591+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
592592
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
593593

594594
/*
@@ -624,7 +624,7 @@ static int aead_setkey(struct crypto_aead *aead,
624624
dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->adata.keylen_pad +
625625
keys.enckeylen, ctx->dir);
626626

627-
print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
627+
print_hex_dump_devel("ctx.key@"__stringify(__LINE__)": ",
628628
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
629629
ctx->adata.keylen_pad + keys.enckeylen, 1);
630630

@@ -665,7 +665,7 @@ static int gcm_setkey(struct crypto_aead *aead,
665665
if (err)
666666
return err;
667667

668-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
668+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
669669
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
670670

671671
memcpy(ctx->key, key, keylen);
@@ -686,7 +686,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
686686
if (err)
687687
return err;
688688

689-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
689+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
690690
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
691691

692692
memcpy(ctx->key, key, keylen);
@@ -712,7 +712,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
712712
if (err)
713713
return err;
714714

715-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
715+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
716716
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
717717

718718
memcpy(ctx->key, key, keylen);
@@ -739,7 +739,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
739739
u32 *desc;
740740
const bool is_rfc3686 = alg->caam.rfc3686;
741741

742-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
742+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
743743
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
744744

745745
ctx->cdata.keylen = keylen;

drivers/crypto/caam/caamalg_qi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
207207
dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
208208
keys.authkeylen + keys.enckeylen, keys.enckeylen,
209209
keys.authkeylen);
210-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
210+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
211211
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
212212

213213
/*
@@ -243,7 +243,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
243243
ctx->adata.keylen_pad + keys.enckeylen,
244244
ctx->dir);
245245

246-
print_hex_dump_debug("ctx.key@" __stringify(__LINE__)": ",
246+
print_hex_dump_devel("ctx.key@" __stringify(__LINE__)": ",
247247
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
248248
ctx->adata.keylen_pad + keys.enckeylen, 1);
249249

@@ -366,7 +366,7 @@ static int gcm_setkey(struct crypto_aead *aead,
366366
if (ret)
367367
return ret;
368368

369-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
369+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
370370
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
371371

372372
memcpy(ctx->key, key, keylen);
@@ -470,7 +470,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
470470
if (ret)
471471
return ret;
472472

473-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
473+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
474474
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
475475

476476
memcpy(ctx->key, key, keylen);
@@ -576,7 +576,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
576576
if (ret)
577577
return ret;
578578

579-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
579+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
580580
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
581581

582582
memcpy(ctx->key, key, keylen);
@@ -626,7 +626,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
626626
const bool is_rfc3686 = alg->caam.rfc3686;
627627
int ret = 0;
628628

629-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
629+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
630630
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
631631

632632
ctx->cdata.keylen = keylen;

drivers/crypto/caam/caamhash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int axcbc_setkey(struct crypto_ahash *ahash, const u8 *key,
495495
DMA_TO_DEVICE);
496496
ctx->adata.keylen = keylen;
497497

498-
print_hex_dump_debug("axcbc ctx.key@" __stringify(__LINE__)" : ",
498+
print_hex_dump_devel("axcbc ctx.key@" __stringify(__LINE__)" : ",
499499
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key, keylen, 1);
500500

501501
return axcbc_set_sh_desc(ahash);
@@ -515,7 +515,7 @@ static int acmac_setkey(struct crypto_ahash *ahash, const u8 *key,
515515
ctx->adata.key_virt = key;
516516
ctx->adata.keylen = keylen;
517517

518-
print_hex_dump_debug("acmac ctx.key@" __stringify(__LINE__)" : ",
518+
print_hex_dump_devel("acmac ctx.key@" __stringify(__LINE__)" : ",
519519
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
520520

521521
return acmac_set_sh_desc(ahash);

drivers/crypto/caam/key_gen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out,
5858

5959
dev_dbg(jrdev, "split keylen %d split keylen padded %d\n",
6060
adata->keylen, adata->keylen_pad);
61-
print_hex_dump_debug("ctx.key@" __stringify(__LINE__)": ",
61+
print_hex_dump_devel("ctx.key@" __stringify(__LINE__)": ",
6262
DUMP_PREFIX_ADDRESS, 16, 4, key_in, keylen, 1);
6363

6464
if (local_max > max_keylen)
@@ -113,7 +113,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out,
113113
wait_for_completion(&result.completion);
114114
ret = result.err;
115115

116-
print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
116+
print_hex_dump_devel("ctx.key@"__stringify(__LINE__)": ",
117117
DUMP_PREFIX_ADDRESS, 16, 4, key_out,
118118
adata->keylen_pad, 1);
119119
}

0 commit comments

Comments
 (0)