crypto: rockchip: set CRYPTO_ALG_INTERNAL for cra_flags

Rockchip's crypto driver is set to the CRYPTO_ALG_INTERNAL flag,
 which prevents it from being called by other modules of the system
 and is only used for librkcrypto use.

Fixed the panic bug caused by calling hmac(sha256) in Android CTS test:

[  234.124644][    C0] ------------[ cut here ]------------
[  234.124694][    C0] kernel BUG at arch/arm64/kernel/fpsimd.c:1832!
[  234.124708][    C0] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
[  234.165910][    C0] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           OE      6.1.78-android14-11-g55b024554aae-ab11965736 #1
[  234.166912][    C0] Hardware name: Rockchip RK3576 EVB1 V10 Board (DT)
[  234.167486][    C0] pstate: 404000c5 (nZcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  234.168160][    C0] pc : kernel_neon_begin+0xe8/0x14c
[  234.168623][    C0] lr : cbc_decrypt+0x94/0x104
[  234.169037][    C0] sp : ffffffc008003ce0
[  234.169393][    C0] x29: ffffffc008003ce0 x28: ffffffc009faed80 x27: 00000000000000e0
[  234.170093][    C0] x26: ffffffc00a13e000 x25: 0000000000000001 x24: ffffff800dd85dc0
[  234.170792][    C0] x23: ffffff80f17e5540 x22: ffffff80f17e5600 x21: 0000000000000002
[  234.171492][    C0] x20: ffffff80c3720d70 x19: ffffffc009faed80 x18: ffffffc008005060
[  234.172192][    C0] x17: 000000000000003c x16: 000000000000003c x15: 000000000000003c
[  234.172891][    C0] x14: 0000000000000000 x13: fffffffe030dc9c0 x12: 000000000000003c
[  234.173590][    C0] x11: 000000000000003c x10: 0000000000000008 x9 : 0000000000000080
[  234.174289][    C0] x8 : 00000000000000c0 x7 : 0000000000000000 x6 : 189055e08898eccd
[  234.174988][    C0] x5 : 000000000000003c x4 : 0000000000000fc4 x3 : 0000000000000020
[  234.175687][    C0] x2 : 0000000000000030 x1 : 0000000000000020 x0 : 0000000000000000
[  234.176387][    C0] Call trace:
[  234.176667][    C0]  kernel_neon_begin+0xe8/0x14c
[  234.177092][    C0]  cbc_decrypt+0x94/0x104
[  234.177472][    C0]  crypto_skcipher_decrypt+0x3c/0x54
[  234.177932][    C0]  crypto_authenc_decrypt_tail+0xd8/0xf4
[  234.178423][    C0]  authenc_verify_ahash_done+0x5c/0x6c
[  234.178902][    C0]  rk_ahash_crypto_complete+0x10c/0x204 [rk_crypto]
[  234.179522][    C0]  rk_complete_op+0x78/0x100 [rk_crypto]
[  234.180049][    C0]  rk_crypto_done_task_cb+0xc8/0x100 [rk_crypto]
[  234.180641][    C0]  tasklet_action_common+0x260/0x4bc
[  234.181100][    C0]  tasklet_action+0x24/0x34
[  234.181492][    C0]  __do_softirq+0x11c/0x418
[  234.181883][    C0]  ____do_softirq+0x10/0x20
[  234.182274][    C0]  call_on_irq_stack+0x3c/0x74
[  234.182687][    C0]  do_softirq_own_stack+0x1c/0x2c
[  234.183121][    C0]  __irq_exit_rcu+0x54/0xb4
[  234.183513][    C0]  irq_exit_rcu+0x10/0x1c
[  234.183893][    C0]  el1_interrupt+0xa4/0xd8
[  234.184276][    C0]  el1h_64_irq_handler+0x18/0x24
[  234.184710][    C0]  el1h_64_irq+0x68/0x6c
[  234.185079][    C0]  cpuidle_enter_state+0x1d0/0x5b4
[  234.185526][    C0]  cpuidle_enter+0x38/0x54
[  234.185905][    C0]  do_idle+0x1d4/0x294
[  234.186268][    C0]  cpu_startup_entry+0x34/0x3c
[  234.186682][    C0]  rest_init+0xe0/0xe4
[  234.187042][    C0]  arch_call_rest_init+0x10/0x14
[  234.187477][    C0]  start_kernel+0x384/0x478
[  234.187866][    C0]  __primary_switched+0xc8/0xd4
[  234.188295][    C0] Code: f85f8e5e d65f03c0 943f17c6 34fffcd5 (d4210000)
[  234.188891][    C0] ---[ end trace 0000000000000000 ]---
[  234.204980][    C0] Kernel panic - not syncing: Oops - BUG: Fatal exception in interrupt

Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
Change-Id: I9bace812173c232f16fd8cb72466d37fae98a5b6
This commit is contained in:
Lin Jinhan
2024-09-10 16:32:44 +08:00
committed by Tao Huang
parent ad889adf73
commit 629aef9788
2 changed files with 15 additions and 8 deletions

View File

@@ -150,7 +150,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
struct ablkcipher_alg *alg;
#endif
out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0);
out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, CRYPTO_ALG_INTERNAL,
CRYPTO_ALG_INTERNAL);
if (unlikely(IS_ERR(out->async.s))) {
ddebug(1, "Failed to load cipher %s", alg_name);
return PTR_ERR(out->async.s);
@@ -194,7 +195,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen);
} else {
out->async.as = crypto_alloc_aead(alg_name, 0, 0);
out->async.as = crypto_alloc_aead(alg_name, CRYPTO_ALG_INTERNAL,
CRYPTO_ALG_INTERNAL);
if (unlikely(IS_ERR(out->async.as))) {
ddebug(1, "Failed to load cipher %s", alg_name);
return PTR_ERR(out->async.as);
@@ -354,7 +356,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name,
{
int ret;
hdata->async.s = crypto_alloc_ahash(alg_name, 0, 0);
hdata->async.s = crypto_alloc_ahash(alg_name, CRYPTO_ALG_INTERNAL, CRYPTO_ALG_INTERNAL);
if (unlikely(IS_ERR(hdata->async.s))) {
ddebug(1, "Failed to load transform for %s", alg_name);
return PTR_ERR(hdata->async.s);

View File

@@ -319,7 +319,8 @@ enum rk_cipher_mode {
.base.cra_flags = CRYPTO_ALG_TYPE_AEAD |\
CRYPTO_ALG_KERN_DRIVER_ONLY |\
CRYPTO_ALG_ASYNC |\
CRYPTO_ALG_NEED_FALLBACK,\
CRYPTO_ALG_NEED_FALLBACK |\
CRYPTO_ALG_INTERNAL,\
.base.cra_blocksize = 1,\
.base.cra_ctxsize = sizeof(struct rk_cipher_ctx),\
.base.cra_alignmask = 0x07,\
@@ -347,7 +348,8 @@ enum rk_cipher_mode {
.base.cra_priority = RK_CRYPTO_PRIORITY,\
.base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY |\
CRYPTO_ALG_ASYNC |\
CRYPTO_ALG_NEED_FALLBACK,\
CRYPTO_ALG_NEED_FALLBACK |\
CRYPTO_ALG_INTERNAL,\
.base.cra_blocksize = cipher_algo##_BLOCK_SIZE,\
.base.cra_ctxsize = sizeof(struct rk_cipher_ctx),\
.base.cra_alignmask = 0x07,\
@@ -375,7 +377,8 @@ enum rk_cipher_mode {
.base.cra_priority = RK_CRYPTO_PRIORITY,\
.base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY |\
CRYPTO_ALG_ASYNC |\
CRYPTO_ALG_NEED_FALLBACK,\
CRYPTO_ALG_NEED_FALLBACK |\
CRYPTO_ALG_INTERNAL,\
.base.cra_blocksize = cipher_algo##_BLOCK_SIZE,\
.base.cra_ctxsize = sizeof(struct rk_cipher_ctx),\
.base.cra_alignmask = 0x07,\
@@ -413,7 +416,8 @@ enum rk_cipher_mode {
.cra_priority = RK_CRYPTO_PRIORITY,\
.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY |\
CRYPTO_ALG_ASYNC |\
CRYPTO_ALG_NEED_FALLBACK,\
CRYPTO_ALG_NEED_FALLBACK |\
CRYPTO_ALG_INTERNAL,\
.cra_blocksize = hash_algo##_BLOCK_SIZE,\
.cra_ctxsize = sizeof(struct rk_ahash_ctx),\
.cra_alignmask = 0,\
@@ -447,7 +451,8 @@ enum rk_cipher_mode {
.cra_priority = RK_CRYPTO_PRIORITY,\
.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY |\
CRYPTO_ALG_ASYNC |\
CRYPTO_ALG_NEED_FALLBACK,\
CRYPTO_ALG_NEED_FALLBACK |\
CRYPTO_ALG_INTERNAL,\
.cra_blocksize = hash_algo##_BLOCK_SIZE,\
.cra_ctxsize = sizeof(struct rk_ahash_ctx),\
.cra_alignmask = 0,\