Message ID | Z-PGEtO8JmyC5xU_@gondor.apana.org.au (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | crypto: sa2ul - Use proper helpers to setup request | expand |
Hi Herbert, On 17:17-20250326, Herbert Xu wrote: > On Wed, Mar 26, 2025 at 02:30:35PM +0530, Manorit Chawdhry wrote: > > > > The following patch seems to be breaking selftests in SA2UL driver. > > Thanks for the report. > > This patch should fix the problem: > > ---8<--- > Rather than setting up a request by hand, use the correct API helpers > to setup the new request. This is because the API helpers will setup > chaining. > > Also change the fallback allocation to explicitly request for a > sync algorithm as this driver will crash if given an async one. > > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > Thanks for the quick fix, though now I see error in import rather than init which was there previously. root@j721e-evm:~# modprobe sa2ul [ 155.283088] omap_rng 4e10000.rng: Random Number Generator ver. 241b34c root@j721e-evm:~# [ 155.401918] Unable to handle kernel paging request at virtual address fefefefefefefeee [ 155.430127] Unable to handle kernel paging request at virtual address fefefefefefefeee [ 155.463959] Unable to handle kernel paging request at virtual address fefefefefefefeee [ 155.480086] Mem abort info: [ 155.503068] Mem abort info: [ 155.506689] ESR = 0x0000000096000004 [ 155.527264] ESR = 0x0000000096000004 [ 155.531009] EC = 0x25: DABT (current EL), IL = 32 bits [ 155.538758] Mem abort info: [ 155.543371] EC = 0x25: DABT (current EL), IL = 32 bits [ 155.559119] ESR = 0x0000000096000004 [ 155.580125] SET = 0, FnV = 0 [ 155.583176] EA = 0, S1PTW = 0 [ 155.589283] EC = 0x25: DABT (current EL), IL = 32 bits [ 155.607886] SET = 0, FnV = 0 [ 155.610938] EA = 0, S1PTW = 0 [ 155.633650] SET = 0, FnV = 0 [ 155.638300] FSC = 0x04: level 0 translation fault [ 155.667607] FSC = 0x04: level 0 translation fault [ 155.673165] EA = 0, S1PTW = 0 [ 155.686121] Data abort info: [ 155.697270] FSC = 0x04: level 0 translation fault [ 155.709990] Data abort info: [ 155.714312] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 155.736268] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 155.745374] Data abort info: [ 155.763508] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 155.770677] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 155.791894] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 155.801343] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 155.815914] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 155.829811] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 155.847633] [fefefefefefefeee] address between user and kernel address ranges [ 155.859395] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 155.872011] [fefefefefefefeee] address between user and kernel address ranges [ 155.893911] [fefefefefefefeee] address between user and kernel address ranges [ 155.901649] Internal error: Oops: 0000000096000004 [#1] SMP [ 155.907297] Modules linked in: des_generic cbc libdes sa2ul authenc onboard_usb_dev rpmsg_ctrl rpmsg_char phy_cadence_torrent phy_cadence_sierra rtc_tps6594 tps6594_esm pinctrl_tps6594 tps6594_pfsm gpio_regmap tps6594_regulator ti_am335x_adc pru_rproc kfifo_buf irq_pruss_intc cdns3 cdns_pltfrm cdns_usb_common snd_soc_j721e_evm display_connector phy_can_transceiver omap_mailbox phy_j721e_wiz ti_k3_r5_remoteproc tps6594_i2c tps6594_core at24 tidss k3_j72xx_bandgap drm_client_lib drm_dma_helper cdns_mhdp8546 ti_am335x_tscadc m_can_platform snd_soc_davinci_mcasp drm_display_helper pruss snd_soc_ti_udma m_can snd_soc_ti_edma drm_kms_helper ti_j721e_ufs snd_soc_ti_sdma ti_k3_dsp_remoteproc snd_soc_pcm3168a_i2c cdns3_ti can_dev snd_soc_pcm3168a rti_wdt overlay cfg80211 rfkill fuse drm backlight ipv6 [ 155.977452] CPU: 0 UID: 0 PID: 1252 Comm: cryptomgr_test Not tainted 6.14.0-rc7-next-20250324-build-configs-00001-g82a16a3a2a73-dirty #3 PREEMPT [ 155.990466] Hardware name: Texas Instruments J721e EVM (DT) [ 155.996022] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 156.002966] pc : crypto_ahash_import+0x18/0x68 [ 156.007409] lr : sa_sha_import+0x48/0x60 [sa2ul] [ 156.012024] sp : ffff8000853336f0 [ 156.015326] x29: ffff8000853336f0 x28: 0000000000000000 x27: 0000000000000000 [ 156.022447] x26: ffff000807ed6c00 x25: ffff8000853337e8 x24: 0000000000000000 [ 156.029568] x23: ffff000801307440 x22: ffff800085333c08 x21: ffff000801307400 [ 156.036688] x20: ffff800081510c10 x19: ffff8000814e13e8 x18: 00000000ffffffff [ 156.043809] x17: 0000000000000000 x16: 0010000000000000 x15: ffff800085333740 [ 156.050929] x14: ffff800105333aa7 x13: 0000000000000000 x12: 0000000000000000 [ 156.058049] x11: 0000000000000000 x10: ffff00087f7c8308 x9 : ffff80007be3aa38 [ 156.065170] x8 : ffff000807ed6d50 x7 : fefefefefefefefe x6 : 0101010101010101 [ 156.072291] x5 : 00000000ffffff8d x4 : 0000000000000000 x3 : fefefefefefefefe [ 156.079411] x2 : ffff000807ed6c00 x1 : ffff000803fc9c00 x0 : ffff000807ed6c90 [ 156.086531] Call trace: [ 156.088966] crypto_ahash_import+0x18/0x68 (P) [ 156.093399] sa_sha_import+0x48/0x60 [sa2ul] [ 156.097658] crypto_ahash_import+0x54/0x68 [ 156.101744] test_ahash_vec_cfg+0x638/0x800 [ 156.105916] test_hash_vec+0xbc/0x230 [ 156.109568] __alg_test_hash+0x288/0x3d8 [ 156.113478] alg_test_hash+0x108/0x1a0 [ 156.117217] alg_test+0x148/0x658 [ 156.120520] cryptomgr_test+0x2c/0x50 [ 156.124171] kthread+0x134/0x218 [ 156.127390] ret_from_fork+0x10/0x20 [ 156.130958] Code: d503233f a9bf7bfd 910003fd f9401003 (385f0064) [ 156.137034] ---[ end trace 0000000000000000 ]--- [ 156.147224] Internal error: Oops: 0000000096000004 [#2] SMP [ 156.152873] Modules linked in: des_generic cbc libdes sa2ul authenc onboard_usb_dev rpmsg_ctrl rpmsg_char phy_cadence_torrent phy_cadence_sierra rtc_tps6594 tps6594_esm pinctrl_tps6594 tps6594_pfsm gpio_regmap tps6594_regulator ti_am335x_adc pru_rproc kfifo_buf irq_pruss_intc cdns3 cdns_pltfrm cdns_usb_common snd_soc_j721e_evm display_connector phy_can_transceiver omap_mailbox phy_j721e_wiz ti_k3_r5_remoteproc tps6594_i2c tps6594_core at24 tidss k3_j72xx_bandgap drm_client_lib drm_dma_helper cdns_mhdp8546 ti_am335x_tscadc m_can_platform snd_soc_davinci_mcasp drm_display_helper pruss snd_soc_ti_udma m_can snd_soc_ti_edma drm_kms_helper ti_j721e_ufs snd_soc_ti_sdma ti_k3_dsp_remoteproc snd_soc_pcm3168a_i2c cdns3_ti can_dev snd_soc_pcm3168a rti_wdt overlay cfg80211 rfkill fuse drm backlight ipv6 [ 156.223015] CPU: 0 UID: 0 PID: 1253 Comm: cryptomgr_test Tainted: G D 6.14.0-rc7-next-20250324-build-configs-00001-g82a16a3a2a73-dirty #3 PREEMPT [ 156.237588] Tainted: [D]=DIE [ 156.240456] Hardware name: Texas Instruments J721e EVM (DT) [ 156.246010] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 156.252953] pc : crypto_ahash_import+0x18/0x68 [ 156.257389] lr : sa_sha_import+0x48/0x60 [sa2ul] [ 156.261998] sp : ffff8000853cb6f0 [ 156.265299] x29: ffff8000853cb6f0 x28: 0000000000000000 x27: 0000000000000000 [ 156.272420] x26: ffff0008033aba00 x25: ffff8000853cb7e8 x24: 0000000000000000 [ 156.279540] x23: ffff000808b8a040 x22: ffff8000853cbc08 x21: ffff000808b8a000 [ 156.286660] x20: ffff800081510970 x19: ffff8000814e13e8 x18: ffff0008033abb28 [ 156.293781] x17: 0000000000000050 x16: 000000000000005e x15: fefefefefefefefe [ 156.300900] x14: fefefefefefefefe x13: fefefefefefefefe x12: fefefefefefefefe [ 156.308021] x11: fefefefefefefefe x10: fefefefefefefefe x9 : ffff80007be3aa38 [ 156.315141] x8 : ffff0008033abbb0 x7 : fefefefefefefefe x6 : 0101010101010101 [ 156.322261] x5 : 00000000ffffff8d x4 : 0000000000000000 x3 : fefefefefefefefe [ 156.329381] x2 : ffff0008033aba00 x1 : ffff00080337da00 x0 : ffff0008033aba90 [ 156.336502] Call trace: [ 156.338937] crypto_ahash_import+0x18/0x68 (P) [ 156.343371] sa_sha_import+0x48/0x60 [sa2ul] [ 156.347630] crypto_ahash_import+0x54/0x68 [ 156.351716] test_ahash_vec_cfg+0x638/0x800 [ 156.355888] test_hash_vec+0xbc/0x230 [ 156.359538] __alg_test_hash+0x288/0x3d8 [ 156.363449] alg_test_hash+0x108/0x1a0 [ 156.367187] alg_test+0x148/0x658 [ 156.370491] cryptomgr_test+0x2c/0x50 [ 156.374141] kthread+0x134/0x218 [ 156.377359] ret_from_fork+0x10/0x20 [ 156.380924] Code: d503233f a9bf7bfd 910003fd f9401003 (385f0064) [ 156.386999] ---[ end trace 0000000000000000 ]--- [ 156.391626] Internal error: Oops: 0000000096000004 [#3] SMP [ 156.397270] Modules linked in: des_generic cbc libdes sa2ul authenc onboard_usb_dev rpmsg_ctrl rpmsg_char phy_cadence_torrent phy_cadence_sierra rtc_tps6594 tps6594_esm pinctrl_tps6594 tps6594_pfsm gpio_regmap tps6594_regulator ti_am335x_adc pru_rproc kfifo_buf irq_pruss_intc cdns3 cdns_pltfrm cdns_usb_common snd_soc_j721e_evm display_connector phy_can_transceiver omap_mailbox phy_j721e_wiz ti_k3_r5_remoteproc tps6594_i2c tps6594_core at24 tidss k3_j72xx_bandgap drm_client_lib drm_dma_helper cdns_mhdp8546 ti_am335x_tscadc m_can_platform snd_soc_davinci_mcasp drm_display_helper pruss snd_soc_ti_udma m_can snd_soc_ti_edma drm_kms_helper ti_j721e_ufs snd_soc_ti_sdma ti_k3_dsp_remoteproc snd_soc_pcm3168a_i2c cdns3_ti can_dev snd_soc_pcm3168a rti_wdt overlay cfg80211 rfkill fuse drm backlight ipv6 [ 156.467403] CPU: 0 UID: 0 PID: 1250 Comm: cryptomgr_test Tainted: G D 6.14.0-rc7-next-20250324-build-configs-00001-g82a16a3a2a73-dirty #3 PREEMPT [ 156.481974] Tainted: [D]=DIE [ 156.484842] Hardware name: Texas Instruments J721e EVM (DT) [ 156.490396] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 156.497340] pc : crypto_ahash_import+0x18/0x68 [ 156.501773] lr : sa_sha_import+0x48/0x60 [sa2ul] [ 156.506379] sp : ffff8000851d36f0 [ 156.509680] x29: ffff8000851d36f0 x28: 0000000000000000 x27: 0000000000000000 [ 156.516800] x26: ffff000803c75400 x25: ffff8000851d37e8 x24: 0000000000000000 [ 156.523920] x23: ffff000808b8b040 x22: ffff8000851d3c08 x21: ffff000808b8b000 [ 156.531040] x20: ffff800081510e98 x19: ffff8000814e13e8 x18: 00000000ffffffff [ 156.538160] x17: 0000000000000000 x16: 0000000000000000 x15: ffff8000851d3740 [ 156.545280] x14: ffff8001051d3aa7 x13: 0000000000000000 x12: 0000000000000000 [ 156.552400] x11: 0000000000000000 x10: ffff00087f7c8308 x9 : ffff80007be3aa38 [ 156.559520] x8 : ffff000803c75548 x7 : fefefefefefefefe x6 : 0101010101010101 [ 156.566641] x5 : 00000000ffffff8d x4 : 0000000000000000 x3 : fefefefefefefefe [ 156.573761] x2 : ffff000803c75400 x1 : ffff000812686a00 x0 : ffff000803c75490 [ 156.580881] Call trace: [ 156.583316] crypto_ahash_import+0x18/0x68 (P) [ 156.587747] sa_sha_import+0x48/0x60 [sa2ul] [ 156.592006] crypto_ahash_import+0x54/0x68 [ 156.596090] test_ahash_vec_cfg+0x638/0x800 [ 156.600261] test_hash_vec+0xbc/0x230 [ 156.603912] __alg_test_hash+0x288/0x3d8 [ 156.607822] alg_test_hash+0x108/0x1a0 [ 156.611560] alg_test+0x148/0x658 [ 156.614864] cryptomgr_test+0x2c/0x50 [ 156.618514] kthread+0x134/0x218 [ 156.621731] ret_from_fork+0x10/0x20 [ 156.625298] Code: d503233f a9bf7bfd 910003fd f9401003 (385f0064) [ 156.631372] ---[ end trace 0000000000000000 ]--- Regards, Manorit
diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c index 091612b066f1..8fae14043262 100644 --- a/drivers/crypto/sa2ul.c +++ b/drivers/crypto/sa2ul.c @@ -1415,22 +1415,13 @@ static int sa_sha_run(struct ahash_request *req) (auth_len >= SA_UNSAFE_DATA_SZ_MIN && auth_len <= SA_UNSAFE_DATA_SZ_MAX)) { struct ahash_request *subreq = &rctx->fallback_req; - int ret = 0; + int ret; ahash_request_set_tfm(subreq, ctx->fallback.ahash); - subreq->base.flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(subreq, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); + ahash_request_set_crypt(subreq, req->src, req->result, auth_len); - crypto_ahash_init(subreq); - - subreq->nbytes = auth_len; - subreq->src = req->src; - subreq->result = req->result; - - ret |= crypto_ahash_update(subreq); - - subreq->nbytes = 0; - - ret |= crypto_ahash_final(subreq); + ret = crypto_ahash_digest(subreq); return ret; } @@ -1502,8 +1493,7 @@ static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base) return ret; if (alg_base) { - ctx->shash = crypto_alloc_shash(alg_base, 0, - CRYPTO_ALG_NEED_FALLBACK); + ctx->shash = crypto_alloc_shash(alg_base, 0, 0); if (IS_ERR(ctx->shash)) { dev_err(sa_k3_dev, "base driver %s couldn't be loaded\n", alg_base); @@ -1511,8 +1501,7 @@ static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base) } /* for fallback */ ctx->fallback.ahash = - crypto_alloc_ahash(alg_base, 0, - CRYPTO_ALG_NEED_FALLBACK); + crypto_alloc_ahash(alg_base, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(ctx->fallback.ahash)) { dev_err(ctx->dev_data->dev, "Could not load fallback driver\n"); @@ -1546,54 +1535,38 @@ static int sa_sha_init(struct ahash_request *req) crypto_ahash_digestsize(tfm), rctx); ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash); - rctx->fallback_req.base.flags = - req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(&rctx->fallback_req, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); + ahash_request_set_crypt(&rctx->fallback_req, NULL, NULL, 0); return crypto_ahash_init(&rctx->fallback_req); } static int sa_sha_update(struct ahash_request *req) { - struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct sa_sha_req_ctx *rctx = ahash_request_ctx(req); - struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm); - ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash); - rctx->fallback_req.base.flags = - req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; - rctx->fallback_req.nbytes = req->nbytes; - rctx->fallback_req.src = req->src; + ahash_request_set_callback(&rctx->fallback_req, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); + ahash_request_set_crypt(&rctx->fallback_req, req->src, NULL, req->nbytes); return crypto_ahash_update(&rctx->fallback_req); } static int sa_sha_final(struct ahash_request *req) { - struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct sa_sha_req_ctx *rctx = ahash_request_ctx(req); - struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm); - ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash); - rctx->fallback_req.base.flags = - req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; - rctx->fallback_req.result = req->result; + ahash_request_set_callback(&rctx->fallback_req, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); + ahash_request_set_crypt(&rctx->fallback_req, NULL, req->result, 0); return crypto_ahash_final(&rctx->fallback_req); } static int sa_sha_finup(struct ahash_request *req) { - struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct sa_sha_req_ctx *rctx = ahash_request_ctx(req); - struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm); - ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash); - rctx->fallback_req.base.flags = - req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; - - rctx->fallback_req.nbytes = req->nbytes; - rctx->fallback_req.src = req->src; - rctx->fallback_req.result = req->result; + ahash_request_set_callback(&rctx->fallback_req, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); + ahash_request_set_crypt(&rctx->fallback_req, req->src, req->result, req->nbytes); return crypto_ahash_finup(&rctx->fallback_req); } @@ -1601,12 +1574,8 @@ static int sa_sha_finup(struct ahash_request *req) static int sa_sha_import(struct ahash_request *req, const void *in) { struct sa_sha_req_ctx *rctx = ahash_request_ctx(req); - struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); - struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm); - ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash); - rctx->fallback_req.base.flags = req->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(&rctx->fallback_req, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); return crypto_ahash_import(&rctx->fallback_req, in); } @@ -1614,12 +1583,9 @@ static int sa_sha_import(struct ahash_request *req, const void *in) static int sa_sha_export(struct ahash_request *req, void *out) { struct sa_sha_req_ctx *rctx = ahash_request_ctx(req); - struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); - struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm); struct ahash_request *subreq = &rctx->fallback_req; - ahash_request_set_tfm(subreq, ctx->fallback.ahash); - subreq->base.flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(subreq, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); return crypto_ahash_export(subreq, out); }