crypto: lib/Kconfig - Hide arch options from user

commit 17ec3e71ba797cdb62164fea9532c81b60f47167 upstream.

The ARCH_MAY_HAVE patch missed arm64, mips and s390.  But it may
also lead to arch options being enabled but ineffective because
of modular/built-in conflicts.

As the primary user of all these options wireguard is selecting
the arch options anyway, make the same selections at the lib/crypto
option level and hide the arch options from the user.

Instead of selecting them centrally from lib/crypto, simply set
the default of each arch option as suggested by Eric Biggers.

Change the Crypto API generic algorithms to select the top-level
lib/crypto options instead of the generic one as otherwise there
is no way to enable the arch options (Eric Biggers).  Introduce a
set of INTERNAL options to work around dependency cycles on the
CONFIG_CRYPTO symbol.

Fixes: 1047e21aecdf ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Arnd Bergmann <arnd@kernel.org>
Closes: https://lore.kernel.org/oe-kbuild-all/202502232152.JC84YDLp-lkp@intel.com/
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Herbert Xu 2025-02-27 15:48:39 +08:00 committed by Greg Kroah-Hartman
parent 4833d0a92b
commit 67727c5764
9 changed files with 63 additions and 45 deletions

View File

@ -3,10 +3,12 @@
menu "Accelerated Cryptographic Algorithms for CPU (arm)" menu "Accelerated Cryptographic Algorithms for CPU (arm)"
config CRYPTO_CURVE25519_NEON config CRYPTO_CURVE25519_NEON
tristate "Public key crypto: Curve25519 (NEON)" tristate
depends on KERNEL_MODE_NEON depends on KERNEL_MODE_NEON
select CRYPTO_KPP
select CRYPTO_LIB_CURVE25519_GENERIC select CRYPTO_LIB_CURVE25519_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 select CRYPTO_ARCH_HAVE_LIB_CURVE25519
default CRYPTO_LIB_CURVE25519_INTERNAL
help help
Curve25519 algorithm Curve25519 algorithm
@ -45,9 +47,10 @@ config CRYPTO_NHPOLY1305_NEON
- NEON (Advanced SIMD) extensions - NEON (Advanced SIMD) extensions
config CRYPTO_POLY1305_ARM config CRYPTO_POLY1305_ARM
tristate "Hash functions: Poly1305 (NEON)" tristate
select CRYPTO_HASH select CRYPTO_HASH
select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 select CRYPTO_ARCH_HAVE_LIB_POLY1305
default CRYPTO_LIB_POLY1305_INTERNAL
help help
Poly1305 authenticator algorithm (RFC7539) Poly1305 authenticator algorithm (RFC7539)
@ -212,9 +215,10 @@ config CRYPTO_AES_ARM_CE
- ARMv8 Crypto Extensions - ARMv8 Crypto Extensions
config CRYPTO_CHACHA20_NEON config CRYPTO_CHACHA20_NEON
tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" tristate
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms stream cipher algorithms

View File

@ -26,10 +26,11 @@ config CRYPTO_NHPOLY1305_NEON
- NEON (Advanced SIMD) extensions - NEON (Advanced SIMD) extensions
config CRYPTO_POLY1305_NEON config CRYPTO_POLY1305_NEON
tristate "Hash functions: Poly1305 (NEON)" tristate
depends on KERNEL_MODE_NEON depends on KERNEL_MODE_NEON
select CRYPTO_HASH select CRYPTO_HASH
select CRYPTO_ARCH_HAVE_LIB_POLY1305 select CRYPTO_ARCH_HAVE_LIB_POLY1305
default CRYPTO_LIB_POLY1305_INTERNAL
help help
Poly1305 authenticator algorithm (RFC7539) Poly1305 authenticator algorithm (RFC7539)
@ -186,11 +187,12 @@ config CRYPTO_AES_ARM64_NEON_BLK
- NEON (Advanced SIMD) extensions - NEON (Advanced SIMD) extensions
config CRYPTO_CHACHA20_NEON config CRYPTO_CHACHA20_NEON
tristate "Ciphers: ChaCha (NEON)" tristate
depends on KERNEL_MODE_NEON depends on KERNEL_MODE_NEON
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_LIB_CHACHA_GENERIC
select CRYPTO_ARCH_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms stream cipher algorithms

View File

@ -12,9 +12,11 @@ config CRYPTO_CRC32_MIPS
Architecture: mips Architecture: mips
config CRYPTO_POLY1305_MIPS config CRYPTO_POLY1305_MIPS
tristate "Hash functions: Poly1305" tristate
depends on MIPS depends on MIPS
select CRYPTO_HASH
select CRYPTO_ARCH_HAVE_LIB_POLY1305 select CRYPTO_ARCH_HAVE_LIB_POLY1305
default CRYPTO_LIB_POLY1305_INTERNAL
help help
Poly1305 authenticator algorithm (RFC7539) Poly1305 authenticator algorithm (RFC7539)
@ -61,10 +63,11 @@ config CRYPTO_SHA512_OCTEON
Architecture: mips OCTEON using crypto instructions, when available Architecture: mips OCTEON using crypto instructions, when available
config CRYPTO_CHACHA_MIPS config CRYPTO_CHACHA_MIPS
tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)" tristate
depends on CPU_MIPS32_R2 depends on CPU_MIPS32_R2
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_ARCH_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms stream cipher algorithms

View File

@ -3,10 +3,12 @@
menu "Accelerated Cryptographic Algorithms for CPU (powerpc)" menu "Accelerated Cryptographic Algorithms for CPU (powerpc)"
config CRYPTO_CURVE25519_PPC64 config CRYPTO_CURVE25519_PPC64
tristate "Public key crypto: Curve25519 (PowerPC64)" tristate
depends on PPC64 && CPU_LITTLE_ENDIAN depends on PPC64 && CPU_LITTLE_ENDIAN
select CRYPTO_KPP
select CRYPTO_LIB_CURVE25519_GENERIC select CRYPTO_LIB_CURVE25519_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 select CRYPTO_ARCH_HAVE_LIB_CURVE25519
default CRYPTO_LIB_CURVE25519_INTERNAL
help help
Curve25519 algorithm Curve25519 algorithm
@ -124,11 +126,12 @@ config CRYPTO_AES_GCM_P10
later CPU. This module supports stitched acceleration for AES/GCM. later CPU. This module supports stitched acceleration for AES/GCM.
config CRYPTO_CHACHA20_P10 config CRYPTO_CHACHA20_P10
tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)" tristate
depends on PPC64 && CPU_LITTLE_ENDIAN && VSX depends on PPC64 && CPU_LITTLE_ENDIAN && VSX
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_LIB_CHACHA_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms stream cipher algorithms

View File

@ -22,7 +22,6 @@ config CRYPTO_CHACHA_RISCV64
tristate "Ciphers: ChaCha" tristate "Ciphers: ChaCha"
depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC
help help
Length-preserving ciphers: ChaCha20 stream cipher algorithm Length-preserving ciphers: ChaCha20 stream cipher algorithm

View File

@ -120,11 +120,12 @@ config CRYPTO_DES_S390
As of z196 the CTR mode is hardware accelerated. As of z196 the CTR mode is hardware accelerated.
config CRYPTO_CHACHA_S390 config CRYPTO_CHACHA_S390
tristate "Ciphers: ChaCha20" tristate
depends on S390 depends on S390
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_LIB_CHACHA_GENERIC
select CRYPTO_ARCH_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) Length-preserving cipher: ChaCha20 stream cipher (RFC 7539)

View File

@ -3,10 +3,12 @@
menu "Accelerated Cryptographic Algorithms for CPU (x86)" menu "Accelerated Cryptographic Algorithms for CPU (x86)"
config CRYPTO_CURVE25519_X86 config CRYPTO_CURVE25519_X86
tristate "Public key crypto: Curve25519 (ADX)" tristate
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_KPP
select CRYPTO_LIB_CURVE25519_GENERIC select CRYPTO_LIB_CURVE25519_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 select CRYPTO_ARCH_HAVE_LIB_CURVE25519
default CRYPTO_LIB_CURVE25519_INTERNAL
help help
Curve25519 algorithm Curve25519 algorithm
@ -348,11 +350,12 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64
Processes 64 blocks in parallel. Processes 64 blocks in parallel.
config CRYPTO_CHACHA20_X86_64 config CRYPTO_CHACHA20_X86_64
tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)" tristate
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_LIB_CHACHA_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA
default CRYPTO_LIB_CHACHA_INTERNAL
help help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms stream cipher algorithms
@ -417,10 +420,12 @@ config CRYPTO_POLYVAL_CLMUL_NI
- CLMUL-NI (carry-less multiplication new instructions) - CLMUL-NI (carry-less multiplication new instructions)
config CRYPTO_POLY1305_X86_64 config CRYPTO_POLY1305_X86_64
tristate "Hash functions: Poly1305 (SSE2/AVX2)" tristate
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_HASH
select CRYPTO_LIB_POLY1305_GENERIC select CRYPTO_LIB_POLY1305_GENERIC
select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 select CRYPTO_ARCH_HAVE_LIB_POLY1305
default CRYPTO_LIB_POLY1305_INTERNAL
help help
Poly1305 authenticator algorithm (RFC7539) Poly1305 authenticator algorithm (RFC7539)

View File

@ -316,7 +316,7 @@ config CRYPTO_ECRDSA
config CRYPTO_CURVE25519 config CRYPTO_CURVE25519
tristate "Curve25519" tristate "Curve25519"
select CRYPTO_KPP select CRYPTO_KPP
select CRYPTO_LIB_CURVE25519_GENERIC select CRYPTO_LIB_CURVE25519_INTERNAL
help help
Curve25519 elliptic curve (RFC7748) Curve25519 elliptic curve (RFC7748)
@ -614,7 +614,7 @@ config CRYPTO_ARC4
config CRYPTO_CHACHA20 config CRYPTO_CHACHA20
tristate "ChaCha" tristate "ChaCha"
select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_LIB_CHACHA_INTERNAL
select CRYPTO_SKCIPHER select CRYPTO_SKCIPHER
help help
The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms
@ -943,7 +943,7 @@ config CRYPTO_POLYVAL
config CRYPTO_POLY1305 config CRYPTO_POLY1305
tristate "Poly1305" tristate "Poly1305"
select CRYPTO_HASH select CRYPTO_HASH
select CRYPTO_LIB_POLY1305_GENERIC select CRYPTO_LIB_POLY1305_INTERNAL
help help
Poly1305 authenticator algorithm (RFC7539) Poly1305 authenticator algorithm (RFC7539)

View File

@ -48,11 +48,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA
accelerated implementation of the ChaCha library interface, accelerated implementation of the ChaCha library interface,
either builtin or as a module. either builtin or as a module.
config CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
tristate
select CRYPTO_ARCH_HAVE_LIB_CHACHA if CRYPTO_LIB_CHACHA=m
select CRYPTO_ARCH_HAVE_LIB_CHACHA if CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA=y
config CRYPTO_LIB_CHACHA_GENERIC config CRYPTO_LIB_CHACHA_GENERIC
tristate tristate
select CRYPTO_LIB_UTILS select CRYPTO_LIB_UTILS
@ -63,9 +58,14 @@ config CRYPTO_LIB_CHACHA_GENERIC
implementation is enabled, this implementation serves the users implementation is enabled, this implementation serves the users
of CRYPTO_LIB_CHACHA. of CRYPTO_LIB_CHACHA.
config CRYPTO_LIB_CHACHA_INTERNAL
tristate
select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n
config CRYPTO_LIB_CHACHA config CRYPTO_LIB_CHACHA
tristate "ChaCha library interface" tristate "ChaCha library interface"
select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n select CRYPTO
select CRYPTO_LIB_CHACHA_INTERNAL
help help
Enable the ChaCha library interface. This interface may be fulfilled Enable the ChaCha library interface. This interface may be fulfilled
by either the generic implementation or an arch-specific one, if one by either the generic implementation or an arch-specific one, if one
@ -78,13 +78,9 @@ config CRYPTO_ARCH_HAVE_LIB_CURVE25519
accelerated implementation of the Curve25519 library interface, accelerated implementation of the Curve25519 library interface,
either builtin or as a module. either builtin or as a module.
config CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519
tristate
select CRYPTO_ARCH_HAVE_LIB_CURVE25519 if CRYPTO_LIB_CURVE25519=m
select CRYPTO_ARCH_HAVE_LIB_CURVE25519 if CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519=y
config CRYPTO_LIB_CURVE25519_GENERIC config CRYPTO_LIB_CURVE25519_GENERIC
tristate tristate
select CRYPTO_LIB_UTILS
help help
This symbol can be depended upon by arch implementations of the This symbol can be depended upon by arch implementations of the
Curve25519 library interface that require the generic code as a Curve25519 library interface that require the generic code as a
@ -92,10 +88,14 @@ config CRYPTO_LIB_CURVE25519_GENERIC
implementation is enabled, this implementation serves the users implementation is enabled, this implementation serves the users
of CRYPTO_LIB_CURVE25519. of CRYPTO_LIB_CURVE25519.
config CRYPTO_LIB_CURVE25519_INTERNAL
tristate
select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
config CRYPTO_LIB_CURVE25519 config CRYPTO_LIB_CURVE25519
tristate "Curve25519 scalar multiplication library" tristate "Curve25519 scalar multiplication library"
select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n select CRYPTO
select CRYPTO_LIB_UTILS select CRYPTO_LIB_CURVE25519_INTERNAL
help help
Enable the Curve25519 library interface. This interface may be Enable the Curve25519 library interface. This interface may be
fulfilled by either the generic implementation or an arch-specific fulfilled by either the generic implementation or an arch-specific
@ -118,11 +118,6 @@ config CRYPTO_ARCH_HAVE_LIB_POLY1305
accelerated implementation of the Poly1305 library interface, accelerated implementation of the Poly1305 library interface,
either builtin or as a module. either builtin or as a module.
config CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305
tristate
select CRYPTO_ARCH_HAVE_LIB_POLY1305 if CRYPTO_LIB_POLY1305=m
select CRYPTO_ARCH_HAVE_LIB_POLY1305 if CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305=y
config CRYPTO_LIB_POLY1305_GENERIC config CRYPTO_LIB_POLY1305_GENERIC
tristate tristate
help help
@ -132,9 +127,14 @@ config CRYPTO_LIB_POLY1305_GENERIC
implementation is enabled, this implementation serves the users implementation is enabled, this implementation serves the users
of CRYPTO_LIB_POLY1305. of CRYPTO_LIB_POLY1305.
config CRYPTO_LIB_POLY1305_INTERNAL
tristate
select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n
config CRYPTO_LIB_POLY1305 config CRYPTO_LIB_POLY1305
tristate "Poly1305 library interface" tristate "Poly1305 library interface"
select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n select CRYPTO
select CRYPTO_LIB_POLY1305_INTERNAL
help help
Enable the Poly1305 library interface. This interface may be fulfilled Enable the Poly1305 library interface. This interface may be fulfilled
by either the generic implementation or an arch-specific one, if one by either the generic implementation or an arch-specific one, if one
@ -142,9 +142,10 @@ config CRYPTO_LIB_POLY1305
config CRYPTO_LIB_CHACHA20POLY1305 config CRYPTO_LIB_CHACHA20POLY1305
tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)" tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)"
depends on CRYPTO select CRYPTO
select CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA
select CRYPTO_LIB_POLY1305 select CRYPTO_LIB_POLY1305
select CRYPTO_LIB_UTILS
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
config CRYPTO_LIB_SHA1 config CRYPTO_LIB_SHA1