Skip to content

Commit ebd37ee

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 425d200 commit ebd37ee

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
@@ -597,7 +597,7 @@ static int aead_setkey(struct crypto_aead *aead,
597597
dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
598598
keys.authkeylen + keys.enckeylen, keys.enckeylen,
599599
keys.authkeylen);
600-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
600+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
601601
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
602602

603603
/*
@@ -633,7 +633,7 @@ static int aead_setkey(struct crypto_aead *aead,
633633
dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->adata.keylen_pad +
634634
keys.enckeylen, ctx->dir);
635635

636-
print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
636+
print_hex_dump_devel("ctx.key@"__stringify(__LINE__)": ",
637637
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
638638
ctx->adata.keylen_pad + keys.enckeylen, 1);
639639

@@ -674,7 +674,7 @@ static int gcm_setkey(struct crypto_aead *aead,
674674
if (err)
675675
return err;
676676

677-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
677+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
678678
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
679679

680680
memcpy(ctx->key, key, keylen);
@@ -695,7 +695,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
695695
if (err)
696696
return err;
697697

698-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
698+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
699699
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
700700

701701
memcpy(ctx->key, key, keylen);
@@ -721,7 +721,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
721721
if (err)
722722
return err;
723723

724-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
724+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
725725
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
726726

727727
memcpy(ctx->key, key, keylen);
@@ -748,7 +748,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
748748
u32 *desc;
749749
const bool is_rfc3686 = alg->caam.rfc3686;
750750

751-
print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
751+
print_hex_dump_devel("key in @"__stringify(__LINE__)": ",
752752
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
753753

754754
ctx->cdata.keylen = keylen;

drivers/crypto/caam/caamalg_qi.c

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

218218
/*
@@ -248,7 +248,7 @@ static int aead_setkey(struct crypto_aead *aead, const u8 *key,
248248
ctx->adata.keylen_pad + keys.enckeylen,
249249
ctx->dir);
250250

251-
print_hex_dump_debug("ctx.key@" __stringify(__LINE__)": ",
251+
print_hex_dump_devel("ctx.key@" __stringify(__LINE__)": ",
252252
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
253253
ctx->adata.keylen_pad + keys.enckeylen, 1);
254254

@@ -371,7 +371,7 @@ static int gcm_setkey(struct crypto_aead *aead,
371371
if (ret)
372372
return ret;
373373

374-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
374+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
375375
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
376376

377377
memcpy(ctx->key, key, keylen);
@@ -475,7 +475,7 @@ static int rfc4106_setkey(struct crypto_aead *aead,
475475
if (ret)
476476
return ret;
477477

478-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
478+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
479479
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
480480

481481
memcpy(ctx->key, key, keylen);
@@ -581,7 +581,7 @@ static int rfc4543_setkey(struct crypto_aead *aead,
581581
if (ret)
582582
return ret;
583583

584-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
584+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
585585
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
586586

587587
memcpy(ctx->key, key, keylen);
@@ -631,7 +631,7 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
631631
const bool is_rfc3686 = alg->caam.rfc3686;
632632
int ret = 0;
633633

634-
print_hex_dump_debug("key in @" __stringify(__LINE__)": ",
634+
print_hex_dump_devel("key in @" __stringify(__LINE__)": ",
635635
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
636636

637637
ctx->cdata.keylen = keylen;

drivers/crypto/caam/caamhash.c

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

508-
print_hex_dump_debug("axcbc ctx.key@" __stringify(__LINE__)" : ",
508+
print_hex_dump_devel("axcbc ctx.key@" __stringify(__LINE__)" : ",
509509
DUMP_PREFIX_ADDRESS, 16, 4, ctx->key, keylen, 1);
510510

511511
return axcbc_set_sh_desc(ahash);
@@ -525,7 +525,7 @@ static int acmac_setkey(struct crypto_ahash *ahash, const u8 *key,
525525
ctx->adata.key_virt = key;
526526
ctx->adata.keylen = keylen;
527527

528-
print_hex_dump_debug("acmac ctx.key@" __stringify(__LINE__)" : ",
528+
print_hex_dump_devel("acmac ctx.key@" __stringify(__LINE__)" : ",
529529
DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
530530

531531
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)