android_kernel_motorola_sm6225/drivers/crypto
Marek Vasut e670c4b7c1 crypto: stm32/crc32 - Fix kernel BUG triggered in probe()
commit 29009604ad4e3ef784fd9b9fef6f23610ddf633d upstream.

The include/linux/crypto.h struct crypto_alg field cra_driver_name description
states "Unique name of the transformation provider. " ... " this contains the
name of the chip or provider and the name of the transformation algorithm."

In case of the stm32-crc driver, field cra_driver_name is identical for all
registered transformation providers and set to the name of the driver itself,
which is incorrect. This patch fixes it by assigning a unique cra_driver_name
to each registered transformation provider.

The kernel crash is triggered when the driver calls crypto_register_shashes()
which calls crypto_register_shash(), which calls crypto_register_alg(), which
calls __crypto_register_alg(), which returns -EEXIST, which is propagated
back through this call chain. Upon -EEXIST from crypto_register_shash(), the
crypto_register_shashes() starts unregistering the providers back, and calls
crypto_unregister_shash(), which calls crypto_unregister_alg(), and this is
where the BUG() triggers due to incorrect cra_refcnt.

Fixes: b51dbe9091 ("crypto: stm32 - Support for STM32 CRC32 crypto module")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: <stable@vger.kernel.org> # 4.12+
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Fabien Dessenne <fabien.dessenne@st.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Lionel Debieve <lionel.debieve@st.com>
Cc: Nicolas Toromanoff <nicolas.toromanoff@st.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
To: linux-crypto@vger.kernel.org
Acked-by: Nicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-27 09:04:31 +01:00
..
amcc crypto: crypto4xx - Replace bitwise OR with logical OR in crypto4xx_build_pd 2020-12-30 11:25:55 +01:00
axis crypto: artpec6 - return correct error code for failed setkey() 2020-02-14 16:33:27 -05:00
bcm crypto: bcm - Rename struct device_private to bcm_device_private 2021-03-04 09:39:39 +01:00
caam crypto: caam - update xts sector size for large input length 2020-04-17 10:48:54 +02:00
cavium crypto: cpt - don't sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified 2020-08-19 08:15:05 +02:00
ccp crypto: ccp - fix resource leaks in ccp_run_aes_gcm_cmd() 2021-10-06 15:31:27 +02:00
ccree crypto: ccree - fix resource leak on error path 2020-08-19 08:14:48 +02:00
chelsio cxgb4/chtls/cxgbit: Keeping the max ofld immediate data size same in cxgb4 and ulds 2021-03-04 09:39:36 +01:00
hisilicon crypto: hisilicon - don't sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified 2020-08-19 08:15:05 +02:00
inside-secure crypto: inside-secure - Fix sizeof() mismatch 2020-12-30 11:25:51 +01:00
marvell crypto: remove redundant type flags from tfm allocation 2018-07-09 00:30:29 +08:00
mediatek cypto: mediatek - fix leaks in mtk_desc_ring_alloc 2020-10-29 09:55:03 +01:00
nx crypto: nx - Fix RCU warning in nx842_OF_upd_status 2021-07-20 16:15:48 +02:00
qat crypto: qat - disregard spurious PFVF interrupts 2021-11-26 11:36:08 +01:00
qce crypto: qce - fix uaf on qce_ahash_register_one 2022-01-27 09:04:17 +01:00
rockchip crypto: rockchip - update IV buffer to contain the next IV 2019-05-22 07:37:37 +02:00
stm32 crypto: stm32/crc32 - Fix kernel BUG triggered in probe() 2022-01-27 09:04:31 +01:00
sunxi-ss crypto: sun4i-ss - handle BigEndian for cipher 2021-03-04 09:39:54 +01:00
ux500 crypto: ux500 - Fix error return code in hash_hw_final() 2021-07-20 16:15:47 +02:00
virtio crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req() 2020-06-22 09:05:06 +02:00
vmx crypto: vmx - Avoid weird build failures 2019-12-31 16:36:13 +01:00
atmel-aes-regs.h
atmel-aes.c crypto: atmel-aes - Fix counter overflow in CTR mode 2020-02-11 04:34:05 -08:00
atmel-authenc.h crypto: atmel - Fix authenc support when it is set to m 2019-12-31 16:35:56 +01:00
atmel-ecc.c crypto: atmel-ecc - remove overly verbose dev_info 2018-06-22 23:03:08 +08:00
atmel-ecc.h
atmel-sha-regs.h
atmel-sha.c crypto: atmel-sha - fix error handling when setting hmac key 2020-02-14 16:33:27 -05:00
atmel-tdes-regs.h
atmel-tdes.c crypto: atmel - Delete error messages for a failed memory allocation in six functions 2018-02-22 22:17:00 +08:00
exynos-rng.c crypto: drivers - simplify getting .drvdata 2018-04-28 16:09:35 +08:00
geode-aes.c crypto: geode-aes - convert to skcipher API and make thread-safe 2020-02-11 04:34:00 -08:00
geode-aes.h crypto: geode-aes - convert to skcipher API and make thread-safe 2020-02-11 04:34:00 -08:00
hifn_795x.c
img-hash.c
ixp4xx_crypto.c crypto: ixp4xx - dma_unmap the correct address 2021-07-20 16:15:46 +02:00
Kconfig crypto: bcm - convert to use crypto_authenc_extractkeys() 2019-01-22 21:40:31 +01:00
Makefile crypto: hisilicon - SEC security accelerator driver 2018-08-03 18:06:02 +08:00
mxc-scc.c crypto: mxc-scc - fix build warnings on ARM64 2019-12-05 09:20:49 +01:00
mxs-dcp.c crypto: mxs-dcp - Use sg_mapping_iter to copy data 2021-09-22 11:48:02 +02:00
n2_asm.S
n2_core.c crypto: ahash - remove useless setting of type flags 2018-07-09 00:30:25 +08:00
n2_core.h
omap-aes-gcm.c
omap-aes.c crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe 2020-12-30 11:25:55 +01:00
omap-aes.h crypto: omap - convert to new crypto engine API 2018-02-15 23:26:51 +08:00
omap-crypto.c crypto: omap-crypto - Verify page zone scatterlists before starting DMA 2018-03-09 22:45:36 +08:00
omap-crypto.h
omap-des.c crypto: omap - convert to new crypto engine API 2018-02-15 23:26:51 +08:00
omap-sham.c crypto: omap-sham - clear dma flags only after omap_sham_update_dma_stop() 2021-09-22 11:47:49 +02:00
padlock-aes.c crypto: padlock-aes - Fix Nano workaround data corruption 2018-07-20 13:47:42 +08:00
padlock-sha.c crypto: shash - remove useless setting of type flags 2018-07-09 00:30:24 +08:00
picoxcell_crypto.c crypto: picoxcell - Fix potential race condition bug 2020-10-29 09:55:01 +01:00
picoxcell_crypto_regs.h
qcom-rng.c crypto: qcom-rng - Add ACPI support 2018-07-27 19:04:32 +08:00
s5p-sss.c crypto: s5p-sss - Add error handling in s5p_aes_probe() 2021-11-26 11:35:57 +01:00
sahara.c crypto: sharah - Unregister correct algorithms for SAHARA 3 2018-07-20 13:51:22 +08:00
talitos.c crypto: talitos - fix max key size for sha384 and sha512 2021-09-26 13:39:47 +02:00
talitos.h crypto: talitos - Work around SEC6 ERRATA (AES-CTR mode data size error) 2021-03-04 09:39:40 +01:00