Skip to content

Commit 4b56770

Browse files
Eric Biggersherbertx
authored andcommitted
crypto: tegra - Add missing CRYPTO_ALG_ASYNC
The tegra crypto driver failed to set the CRYPTO_ALG_ASYNC on its asynchronous algorithms, causing the crypto API to select them for users that request only synchronous algorithms. This causes crashes (at least). Fix this by adding the flag like what the other drivers do. Also remove the unnecessary CRYPTO_ALG_TYPE_* flags, since those just get ignored and overridden by the registration function anyway. Reported-by: Zorro Lang <zlang@redhat.com> Closes: https://lore.kernel.org/r/20260314080937.pghb4aa7d4je3mhh@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com Fixes: 0880bb3 ("crypto: tegra - Add Tegra Security Engine driver") Cc: stable@vger.kernel.org Cc: Akhil R <akhilrajeev@nvidia.com> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 5c52607 commit 4b56770

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

drivers/crypto/tegra/tegra-se-aes.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static struct tegra_se_alg tegra_aes_algs[] = {
529529
.cra_name = "cbc(aes)",
530530
.cra_driver_name = "cbc-aes-tegra",
531531
.cra_priority = 500,
532-
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_ASYNC,
532+
.cra_flags = CRYPTO_ALG_ASYNC,
533533
.cra_blocksize = AES_BLOCK_SIZE,
534534
.cra_ctxsize = sizeof(struct tegra_aes_ctx),
535535
.cra_alignmask = 0xf,
@@ -550,7 +550,7 @@ static struct tegra_se_alg tegra_aes_algs[] = {
550550
.cra_name = "ecb(aes)",
551551
.cra_driver_name = "ecb-aes-tegra",
552552
.cra_priority = 500,
553-
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_ASYNC,
553+
.cra_flags = CRYPTO_ALG_ASYNC,
554554
.cra_blocksize = AES_BLOCK_SIZE,
555555
.cra_ctxsize = sizeof(struct tegra_aes_ctx),
556556
.cra_alignmask = 0xf,
@@ -572,7 +572,7 @@ static struct tegra_se_alg tegra_aes_algs[] = {
572572
.cra_name = "ctr(aes)",
573573
.cra_driver_name = "ctr-aes-tegra",
574574
.cra_priority = 500,
575-
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_ASYNC,
575+
.cra_flags = CRYPTO_ALG_ASYNC,
576576
.cra_blocksize = 1,
577577
.cra_ctxsize = sizeof(struct tegra_aes_ctx),
578578
.cra_alignmask = 0xf,
@@ -594,6 +594,7 @@ static struct tegra_se_alg tegra_aes_algs[] = {
594594
.cra_name = "xts(aes)",
595595
.cra_driver_name = "xts-aes-tegra",
596596
.cra_priority = 500,
597+
.cra_flags = CRYPTO_ALG_ASYNC,
597598
.cra_blocksize = AES_BLOCK_SIZE,
598599
.cra_ctxsize = sizeof(struct tegra_aes_ctx),
599600
.cra_alignmask = (__alignof__(u64) - 1),
@@ -1922,6 +1923,7 @@ static struct tegra_se_alg tegra_aead_algs[] = {
19221923
.cra_name = "gcm(aes)",
19231924
.cra_driver_name = "gcm-aes-tegra",
19241925
.cra_priority = 500,
1926+
.cra_flags = CRYPTO_ALG_ASYNC,
19251927
.cra_blocksize = 1,
19261928
.cra_ctxsize = sizeof(struct tegra_aead_ctx),
19271929
.cra_alignmask = 0xf,
@@ -1944,6 +1946,7 @@ static struct tegra_se_alg tegra_aead_algs[] = {
19441946
.cra_name = "ccm(aes)",
19451947
.cra_driver_name = "ccm-aes-tegra",
19461948
.cra_priority = 500,
1949+
.cra_flags = CRYPTO_ALG_ASYNC,
19471950
.cra_blocksize = 1,
19481951
.cra_ctxsize = sizeof(struct tegra_aead_ctx),
19491952
.cra_alignmask = 0xf,
@@ -1971,7 +1974,7 @@ static struct tegra_se_alg tegra_cmac_algs[] = {
19711974
.cra_name = "cmac(aes)",
19721975
.cra_driver_name = "tegra-se-cmac",
19731976
.cra_priority = 300,
1974-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
1977+
.cra_flags = CRYPTO_ALG_ASYNC,
19751978
.cra_blocksize = AES_BLOCK_SIZE,
19761979
.cra_ctxsize = sizeof(struct tegra_cmac_ctx),
19771980
.cra_alignmask = 0,

drivers/crypto/tegra/tegra-se-hash.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
761761
.cra_name = "sha1",
762762
.cra_driver_name = "tegra-se-sha1",
763763
.cra_priority = 300,
764-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
764+
.cra_flags = CRYPTO_ALG_ASYNC,
765765
.cra_blocksize = SHA1_BLOCK_SIZE,
766766
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
767767
.cra_alignmask = 0,
@@ -786,7 +786,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
786786
.cra_name = "sha224",
787787
.cra_driver_name = "tegra-se-sha224",
788788
.cra_priority = 300,
789-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
789+
.cra_flags = CRYPTO_ALG_ASYNC,
790790
.cra_blocksize = SHA224_BLOCK_SIZE,
791791
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
792792
.cra_alignmask = 0,
@@ -811,7 +811,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
811811
.cra_name = "sha256",
812812
.cra_driver_name = "tegra-se-sha256",
813813
.cra_priority = 300,
814-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
814+
.cra_flags = CRYPTO_ALG_ASYNC,
815815
.cra_blocksize = SHA256_BLOCK_SIZE,
816816
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
817817
.cra_alignmask = 0,
@@ -836,7 +836,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
836836
.cra_name = "sha384",
837837
.cra_driver_name = "tegra-se-sha384",
838838
.cra_priority = 300,
839-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
839+
.cra_flags = CRYPTO_ALG_ASYNC,
840840
.cra_blocksize = SHA384_BLOCK_SIZE,
841841
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
842842
.cra_alignmask = 0,
@@ -861,7 +861,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
861861
.cra_name = "sha512",
862862
.cra_driver_name = "tegra-se-sha512",
863863
.cra_priority = 300,
864-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
864+
.cra_flags = CRYPTO_ALG_ASYNC,
865865
.cra_blocksize = SHA512_BLOCK_SIZE,
866866
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
867867
.cra_alignmask = 0,
@@ -886,7 +886,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
886886
.cra_name = "sha3-224",
887887
.cra_driver_name = "tegra-se-sha3-224",
888888
.cra_priority = 300,
889-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
889+
.cra_flags = CRYPTO_ALG_ASYNC,
890890
.cra_blocksize = SHA3_224_BLOCK_SIZE,
891891
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
892892
.cra_alignmask = 0,
@@ -911,7 +911,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
911911
.cra_name = "sha3-256",
912912
.cra_driver_name = "tegra-se-sha3-256",
913913
.cra_priority = 300,
914-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
914+
.cra_flags = CRYPTO_ALG_ASYNC,
915915
.cra_blocksize = SHA3_256_BLOCK_SIZE,
916916
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
917917
.cra_alignmask = 0,
@@ -936,7 +936,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
936936
.cra_name = "sha3-384",
937937
.cra_driver_name = "tegra-se-sha3-384",
938938
.cra_priority = 300,
939-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
939+
.cra_flags = CRYPTO_ALG_ASYNC,
940940
.cra_blocksize = SHA3_384_BLOCK_SIZE,
941941
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
942942
.cra_alignmask = 0,
@@ -961,7 +961,7 @@ static struct tegra_se_alg tegra_hash_algs[] = {
961961
.cra_name = "sha3-512",
962962
.cra_driver_name = "tegra-se-sha3-512",
963963
.cra_priority = 300,
964-
.cra_flags = CRYPTO_ALG_TYPE_AHASH,
964+
.cra_flags = CRYPTO_ALG_ASYNC,
965965
.cra_blocksize = SHA3_512_BLOCK_SIZE,
966966
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
967967
.cra_alignmask = 0,
@@ -988,7 +988,8 @@ static struct tegra_se_alg tegra_hash_algs[] = {
988988
.cra_name = "hmac(sha224)",
989989
.cra_driver_name = "tegra-se-hmac-sha224",
990990
.cra_priority = 300,
991-
.cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_NEED_FALLBACK,
991+
.cra_flags = CRYPTO_ALG_ASYNC |
992+
CRYPTO_ALG_NEED_FALLBACK,
992993
.cra_blocksize = SHA224_BLOCK_SIZE,
993994
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
994995
.cra_alignmask = 0,
@@ -1015,7 +1016,8 @@ static struct tegra_se_alg tegra_hash_algs[] = {
10151016
.cra_name = "hmac(sha256)",
10161017
.cra_driver_name = "tegra-se-hmac-sha256",
10171018
.cra_priority = 300,
1018-
.cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_NEED_FALLBACK,
1019+
.cra_flags = CRYPTO_ALG_ASYNC |
1020+
CRYPTO_ALG_NEED_FALLBACK,
10191021
.cra_blocksize = SHA256_BLOCK_SIZE,
10201022
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
10211023
.cra_alignmask = 0,
@@ -1042,7 +1044,8 @@ static struct tegra_se_alg tegra_hash_algs[] = {
10421044
.cra_name = "hmac(sha384)",
10431045
.cra_driver_name = "tegra-se-hmac-sha384",
10441046
.cra_priority = 300,
1045-
.cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_NEED_FALLBACK,
1047+
.cra_flags = CRYPTO_ALG_ASYNC |
1048+
CRYPTO_ALG_NEED_FALLBACK,
10461049
.cra_blocksize = SHA384_BLOCK_SIZE,
10471050
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
10481051
.cra_alignmask = 0,
@@ -1069,7 +1072,8 @@ static struct tegra_se_alg tegra_hash_algs[] = {
10691072
.cra_name = "hmac(sha512)",
10701073
.cra_driver_name = "tegra-se-hmac-sha512",
10711074
.cra_priority = 300,
1072-
.cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_NEED_FALLBACK,
1075+
.cra_flags = CRYPTO_ALG_ASYNC |
1076+
CRYPTO_ALG_NEED_FALLBACK,
10731077
.cra_blocksize = SHA512_BLOCK_SIZE,
10741078
.cra_ctxsize = sizeof(struct tegra_sha_ctx),
10751079
.cra_alignmask = 0,

0 commit comments

Comments
 (0)