Skip to contentSkip to conversation

crypto: loongson - Remove broken and unused loongson-rng

PATCH In review Eric Biggers 2 participants 2 messages May 29 – Jun 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: loongson - Remove broken and unused loongson-rng

The loongson-rng rng_alg has several vulnerabilities, including not providing forward security, and a use-after-free bug due to the use of wait_for_completion_interruptible().

Meanwhile, the rng_alg framework doesn't really have any purpose in the first place other than to access the software algorithms crypto/drbg.c and crypto/jitterentropy.c. Hardware-specific rng_algs have no in-kernel user, and unlike hwrng there's no feed into the actual Linux RNG. As such, there's really no point to this code. There are of course other rng_alg drivers that are similarly unused, but they're similarly in the process of being phased out, e.g.
https://lore.kernel.org/r/[email protected] and
https://lore.kernel.org/r/[email protected]

Given that, there's no point in fixing forward these vulnerabilities, and it makes much more sense to simply roll back the addition of this driver. If this platform provides TRNG (not PRNG) functionality, it could make sense to add a hwrng driver, but it would be quite different.

Fixes 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
---
 MAINTAINERS                                 |   1 -
 arch/loongarch/configs/loongson32_defconfig |   1 -
 arch/loongarch/configs/loongson64_defconfig |   1 -
 drivers/crypto/Kconfig                      |   1 -
 drivers/crypto/Makefile                     |   1 -
 drivers/crypto/loongson/Kconfig             |   6 -
 drivers/crypto/loongson/Makefile            |   1 -
 drivers/crypto/loongson/loongson-rng.c      | 209 --------------------
 8 files changed, 221 deletions(-)
 delete mode 100644 drivers/crypto/loongson/Kconfig
 delete mode 100644 drivers/crypto/loongson/Makefile
 delete mode 100644 drivers/crypto/loongson/loongson-rng.c
MAINTAINERS +0 -1
index 882214b0e7db..6c805560c77c 100644
@@ -15068,11 +15068,10 @@ F:	drivers/pwm/pwm-loongson.c
 LOONGSON SECURITY ENGINE DRIVERS
 M:	Qunqin Zhao <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/char/tpm/tpm_loongson.c
-F:	drivers/crypto/loongson/
 F:	drivers/mfd/loongson-se.c
 F:	include/linux/mfd/loongson-se.h
 
 LOONGSON-2 SOC SERIES CLOCK DRIVER
 M:	Yinbo Zhu <[email protected]>
arch/loongarch/configs/loongson32_defconfig +0 -1
index d5ef396dffe3..82897236863f 100644
@@ -1089,11 +1089,10 @@ CONFIG_CRYPTO_LZ4HC=m
 CONFIG_CRYPTO_USER_API_HASH=m
 CONFIG_CRYPTO_USER_API_SKCIPHER=m
 CONFIG_CRYPTO_USER_API_RNG=m
 CONFIG_CRYPTO_USER_API_AEAD=m
 CONFIG_CRYPTO_DEV_VIRTIO=m
-CONFIG_CRYPTO_DEV_LOONGSON_RNG=m
 CONFIG_DMA_CMA=y
 CONFIG_CMA_SIZE_MBYTES=0
 CONFIG_PRINTK_TIME=y
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_MAGIC_SYSRQ=y
arch/loongarch/configs/loongson64_defconfig +0 -1
index cba4cdff5acd..a94e88bd7ec5 100644
@@ -1122,11 +1122,10 @@ CONFIG_CRYPTO_LZ4HC=m
 CONFIG_CRYPTO_USER_API_HASH=m
 CONFIG_CRYPTO_USER_API_SKCIPHER=m
 CONFIG_CRYPTO_USER_API_RNG=m
 CONFIG_CRYPTO_USER_API_AEAD=m
 CONFIG_CRYPTO_DEV_VIRTIO=m
-CONFIG_CRYPTO_DEV_LOONGSON_RNG=m
 CONFIG_DMA_CMA=y
 CONFIG_DMA_NUMA_CMA=y
 CONFIG_CMA_SIZE_MBYTES=0
 CONFIG_PRINTK_TIME=y
 CONFIG_STRIP_ASM_SYMS=y
drivers/crypto/Kconfig +0 -1
index 3449b3c9c6ad..075ec9432789 100644
@@ -844,11 +844,10 @@ config CRYPTO_DEV_CCREE
 	  Choose this if you wish to use hardware acceleration of
 	  cryptographic operations on the system REE.
 	  If unsure say Y.
 
 source "drivers/crypto/hisilicon/Kconfig"
-source "drivers/crypto/loongson/Kconfig"
 
 source "drivers/crypto/amlogic/Kconfig"
 
 config CRYPTO_DEV_SA2UL
 	tristate "Support for TI security accelerator"
drivers/crypto/Makefile +0 -1
index 283bbc650b5b..ad773158ae56 100644
@@ -41,11 +41,10 @@ obj-$(CONFIG_CRYPTO_DEV_VIRTIO) += virtio/
 obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/
 obj-y += inside-secure/
 obj-$(CONFIG_CRYPTO_DEV_ARTPEC6) += axis/
 obj-y += xilinx/
 obj-y += hisilicon/
-obj-y += loongson/
 obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
 obj-y += intel/
 obj-y += starfive/
 obj-y += cavium/
 obj-y += ti/
drivers/crypto/loongson/Kconfig deleted +0 -6
deleted file mode 100644
index f4e1544ffbb4..000000000000
@@ -1,6 +0,0 @@
-config CRYPTO_DEV_LOONGSON_RNG
-	tristate "Support for Loongson RNG Driver"
-	depends on MFD_LOONGSON_SE
-	select CRYPTO_RNG
-	help
-	  Support for Loongson RNG Driver.
drivers/crypto/loongson/Makefile deleted +0 -1
deleted file mode 100644
index 1ce5ec32b553..000000000000
@@ -1 +0,0 @@
-obj-$(CONFIG_CRYPTO_DEV_LOONGSON_RNG)  += loongson-rng.o
drivers/crypto/loongson/loongson-rng.c deleted +0 -209

209 lines not on this page · raw message

base-commit: 5624ea54f3ba5c83d2e5503411a31a8be0278c1e

Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 23 lines · Eric Biggers

The loongson-rng rng_alg has several vulnerabilities, including not providing forward security, and a use-after-free bug due to the use of wait_for_completion_interruptible().

Meanwhile, the rng_alg framework doesn't really have any purpose in the first place other than to access the software algorithms crypto/drbg.c and crypto/jitterentropy.c. Hardware-specific rng_algs have no in-kernel user, and unlike hwrng there's no feed into the actual Linux RNG. As such, there's really no point to this code. There are of course other rng_alg drivers that are similarly unused, but they're similarly in the process of being phased out, e.g.
https://lore.kernel.org/r/[email protected] and
https://lore.kernel.org/r/[email protected]

Given that, there's no point in fixing forward these vulnerabilities, and it makes much more sense to simply roll back the addition of this driver. If this platform provides TRNG (not PRNG) functionality, it could make sense to add a hwrng driver, but it would be quite different.

Fixes 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
Quoted 13 lines
---
 MAINTAINERS                                 |   1 -
 arch/loongarch/configs/loongson32_defconfig |   1 -
 arch/loongarch/configs/loongson64_defconfig |   1 -
 drivers/crypto/Kconfig                      |   1 -
 drivers/crypto/Makefile                     |   1 -
 drivers/crypto/loongson/Kconfig             |   6 -
 drivers/crypto/loongson/Makefile            |   1 -
 drivers/crypto/loongson/loongson-rng.c      | 209 --------------------
 8 files changed, 221 deletions(-)
 delete mode 100644 drivers/crypto/loongson/Kconfig
 delete mode 100644 drivers/crypto/loongson/Makefile
 delete mode 100644 drivers/crypto/loongson/loongson-rng.c

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt