* [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more
@ 2025-02-25 16:42 Arnd Bergmann
2025-02-25 21:33 ` Will Deacon
0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2025-02-25 16:42 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Arnd Bergmann, Christian Borntraeger, Sven Schnelle,
Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James Bottomley,
Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel,
linux-mips, linux-s390
From: Arnd Bergmann <arnd@arndb.de>
A recent change tries to fix Kconfig dependencies, but introduced
two problems in the process:
- only arm, powerpc and x86 are changed, while mips, arm64 and s390
are now broken
- there are now configurations where the architecture enables its
own helper functions as loadable modules, but they remain silently
unused because CRYPTO_LIB_* falls back to the generic helpers
Address both by changing the logic again: the architecture functions
select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA, which may be a loadable
module or built-in, and this controls whether the library is
also built-in.
Fixes: 04f9ccc955c7 ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I did not quite understand what problem the 04f9ccc955c7 patch
actually tried to solve, so there is a chance that my version
undoes it. I tested this on randconfig builds across, arm,
arm64 and x86 and found no other dependency problems with these
libraries.
---
arch/arm64/crypto/Kconfig | 4 ++--
arch/mips/crypto/Kconfig | 4 ++--
arch/s390/crypto/Kconfig | 2 +-
lib/crypto/Kconfig | 20 +++++++++++---------
4 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig
index 5636ab83f22a..3d90efdcf5a5 100644
--- a/arch/arm64/crypto/Kconfig
+++ b/arch/arm64/crypto/Kconfig
@@ -29,7 +29,7 @@ config CRYPTO_POLY1305_NEON
tristate "Hash functions: Poly1305 (NEON)"
depends on KERNEL_MODE_NEON
select CRYPTO_HASH
- select CRYPTO_ARCH_HAVE_LIB_POLY1305
+ select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305
help
Poly1305 authenticator algorithm (RFC7539)
@@ -190,7 +190,7 @@ config CRYPTO_CHACHA20_NEON
depends on KERNEL_MODE_NEON
select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC
- select CRYPTO_ARCH_HAVE_LIB_CHACHA
+ select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms
diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig
index 7decd40c4e20..cbeb2f62eb79 100644
--- a/arch/mips/crypto/Kconfig
+++ b/arch/mips/crypto/Kconfig
@@ -5,7 +5,7 @@ menu "Accelerated Cryptographic Algorithms for CPU (mips)"
config CRYPTO_POLY1305_MIPS
tristate "Hash functions: Poly1305"
depends on MIPS
- select CRYPTO_ARCH_HAVE_LIB_POLY1305
+ select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305
help
Poly1305 authenticator algorithm (RFC7539)
@@ -55,7 +55,7 @@ config CRYPTO_CHACHA_MIPS
tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)"
depends on CPU_MIPS32_R2
select CRYPTO_SKCIPHER
- select CRYPTO_ARCH_HAVE_LIB_CHACHA
+ select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
help
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
stream cipher algorithms
diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig
index b760232537f1..6f7495264943 100644
--- a/arch/s390/crypto/Kconfig
+++ b/arch/s390/crypto/Kconfig
@@ -112,7 +112,7 @@ config CRYPTO_CHACHA_S390
depends on S390
select CRYPTO_SKCIPHER
select CRYPTO_LIB_CHACHA_GENERIC
- select CRYPTO_ARCH_HAVE_LIB_CHACHA
+ select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
help
Length-preserving cipher: ChaCha20 stream cipher (RFC 7539)
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index c542ef1d64d0..6b45bd634cd9 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -50,8 +50,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA
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
tristate
@@ -65,7 +63,9 @@ config CRYPTO_LIB_CHACHA_GENERIC
config CRYPTO_LIB_CHACHA
tristate "ChaCha library interface"
- select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n
+ select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA=n
+ select CRYPTO_ARCH_HAVE_LIB_CHACHA if CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA!=n
+ depends on CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA || !CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
help
Enable the ChaCha library interface. This interface may be fulfilled
by either the generic implementation or an arch-specific one, if one
@@ -80,8 +80,6 @@ config CRYPTO_ARCH_HAVE_LIB_CURVE25519
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
tristate
@@ -94,7 +92,9 @@ config CRYPTO_LIB_CURVE25519_GENERIC
config CRYPTO_LIB_CURVE25519
tristate "Curve25519 scalar multiplication library"
- select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
+ select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519=n
+ select CRYPTO_ARCH_HAVE_LIB_CURVE25519 if CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519!=n
+ depends on CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 || !CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519
select CRYPTO_LIB_UTILS
help
Enable the Curve25519 library interface. This interface may be
@@ -120,8 +120,6 @@ config CRYPTO_ARCH_HAVE_LIB_POLY1305
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
tristate
@@ -134,7 +132,9 @@ config CRYPTO_LIB_POLY1305_GENERIC
config CRYPTO_LIB_POLY1305
tristate "Poly1305 library interface"
- select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n
+ select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305=n
+ select CRYPTO_ARCH_HAVE_LIB_POLY1305 if CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305!=n
+ depends on CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 || !CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305
help
Enable the Poly1305 library interface. This interface may be fulfilled
by either the generic implementation or an arch-specific one, if one
@@ -143,6 +143,8 @@ config CRYPTO_LIB_POLY1305
config CRYPTO_LIB_CHACHA20POLY1305
tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)"
depends on CRYPTO
+ depends on CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 || !CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305
+ depends on CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA || !CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA
select CRYPTO_LIB_CHACHA
select CRYPTO_LIB_POLY1305
select CRYPTO_ALGAPI
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more 2025-02-25 16:42 [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more Arnd Bergmann @ 2025-02-25 21:33 ` Will Deacon 2025-02-25 21:40 ` Arnd Bergmann 0 siblings, 1 reply; 17+ messages in thread From: Will Deacon @ 2025-02-25 21:33 UTC (permalink / raw) To: Arnd Bergmann Cc: Herbert Xu, David S. Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Arnd Bergmann, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Tue, Feb 25, 2025 at 05:42:07PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > A recent change tries to fix Kconfig dependencies, but introduced > two problems in the process: > > - only arm, powerpc and x86 are changed, while mips, arm64 and s390 > are now broken > > - there are now configurations where the architecture enables its > own helper functions as loadable modules, but they remain silently > unused because CRYPTO_LIB_* falls back to the generic helpers > > Address both by changing the logic again: the architecture functions > select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA, which may be a loadable > module or built-in, and this controls whether the library is > also built-in. > > Fixes: 04f9ccc955c7 ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") Which tree contains this change? I can't seem to resolve the SHA locally. Will ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more 2025-02-25 21:33 ` Will Deacon @ 2025-02-25 21:40 ` Arnd Bergmann 2025-02-25 21:50 ` Arnd Bergmann 0 siblings, 1 reply; 17+ messages in thread From: Arnd Bergmann @ 2025-02-25 21:40 UTC (permalink / raw) To: Will Deacon, Arnd Bergmann Cc: Herbert Xu, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Tue, Feb 25, 2025, at 22:33, Will Deacon wrote: > On Tue, Feb 25, 2025 at 05:42:07PM +0100, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> A recent change tries to fix Kconfig dependencies, but introduced >> two problems in the process: >> >> - only arm, powerpc and x86 are changed, while mips, arm64 and s390 >> are now broken >> >> - there are now configurations where the architecture enables its >> own helper functions as loadable modules, but they remain silently >> unused because CRYPTO_LIB_* falls back to the generic helpers >> >> Address both by changing the logic again: the architecture functions >> select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA, which may be a loadable >> module or built-in, and this controls whether the library is >> also built-in. >> >> Fixes: 04f9ccc955c7 ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") > > Which tree contains this change? I can't seem to resolve the SHA locally. Sorry, that must have been an older commit ID. Today's linux-next contains 56b8e4bb7622 ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") which is in git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more 2025-02-25 21:40 ` Arnd Bergmann @ 2025-02-25 21:50 ` Arnd Bergmann 2025-02-26 1:40 ` Herbert Xu 0 siblings, 1 reply; 17+ messages in thread From: Arnd Bergmann @ 2025-02-25 21:50 UTC (permalink / raw) To: Arnd Bergmann, Will Deacon Cc: Herbert Xu, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Tue, Feb 25, 2025, at 22:40, Arnd Bergmann wrote: > On Tue, Feb 25, 2025, at 22:33, Will Deacon wrote: >> On Tue, Feb 25, 2025 at 05:42:07PM +0100, Arnd Bergmann wrote: >>> From: Arnd Bergmann <arnd@arndb.de> >>> >>> A recent change tries to fix Kconfig dependencies, but introduced >>> two problems in the process: >>> >>> - only arm, powerpc and x86 are changed, while mips, arm64 and s390 >>> are now broken >>> >>> - there are now configurations where the architecture enables its >>> own helper functions as loadable modules, but they remain silently >>> unused because CRYPTO_LIB_* falls back to the generic helpers >>> >>> Address both by changing the logic again: the architecture functions >>> select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA, which may be a loadable >>> module or built-in, and this controls whether the library is >>> also built-in. >>> >>> Fixes: 04f9ccc955c7 ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") >> >> Which tree contains this change? I can't seem to resolve the SHA locally. > > Sorry, that must have been an older commit ID. Today's linux-next > contains 56b8e4bb7622 ("crypto: lib/Kconfig - Fix lib built-in failure > when arch is modular") > > which is in > git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git After looking at the original 0day report, I think the fix for that problem would have been --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -94,6 +94,7 @@ config WIREGUARD select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 select CRYPTO_POLY1305_MIPS if MIPS select CRYPTO_CHACHA_S390 if S390 + select CRYPTO_CURVE25519_PPC64 if PPC64 && CPU_LITTLE_ENDIAN help WireGuard is a secure, fast, and easy to use replacement for IPSec that uses modern cryptography and clever networking tricks. It's which makes powerpc behave the same way as the other architectures. Ideally wireguard should not need to know about every architecture specific algorithm that it might use though, and that requires a different method of enabling those. Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more 2025-02-25 21:50 ` Arnd Bergmann @ 2025-02-26 1:40 ` Herbert Xu 2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu 0 siblings, 1 reply; 17+ messages in thread From: Herbert Xu @ 2025-02-26 1:40 UTC (permalink / raw) To: Arnd Bergmann Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Tue, Feb 25, 2025 at 10:50:10PM +0100, Arnd Bergmann wrote: > > After looking at the original 0day report, I think the fix for > that problem would have been > > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -94,6 +94,7 @@ config WIREGUARD > select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 > select CRYPTO_POLY1305_MIPS if MIPS > select CRYPTO_CHACHA_S390 if S390 > + select CRYPTO_CURVE25519_PPC64 if PPC64 && CPU_LITTLE_ENDIAN > help > WireGuard is a secure, fast, and easy to use replacement for IPSec > that uses modern cryptography and clever networking tricks. It's Thanks. I wasn't aware wireguard was doing this. Let me see if I can replicate this select matrix in lib/crypto instead. Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH] crypto: lib/Kconfig - Select and hide arch options 2025-02-26 1:40 ` Herbert Xu @ 2025-02-26 4:36 ` Herbert Xu 2025-02-26 6:07 ` Eric Biggers ` (3 more replies) 0 siblings, 4 replies; 17+ messages in thread From: Herbert Xu @ 2025-02-26 4:36 UTC (permalink / raw) To: Arnd Bergmann Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 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. 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> diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 47d9cc59f254..e28c177e63d3 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (arm)" config CRYPTO_CURVE25519_NEON - tristate "Public key crypto: Curve25519 (NEON)" + tristate depends on KERNEL_MODE_NEON - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -45,9 +45,9 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_ARM - tristate "Hash functions: Poly1305 (NEON)" + tristate select CRYPTO_HASH - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -212,9 +212,9 @@ config CRYPTO_AES_ARM_CE - ARMv8 Crypto Extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" + tristate select CRYPTO_SKCIPHER - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 5636ab83f22a..6bf844da022d 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -26,7 +26,7 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_NEON - tristate "Hash functions: Poly1305 (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 @@ -186,10 +186,9 @@ config CRYPTO_AES_ARM64_NEON_BLK - NEON (Advanced SIMD) extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 7decd40c4e20..e02481cc9c06 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -3,8 +3,9 @@ menu "Accelerated Cryptographic Algorithms for CPU (mips)" config CRYPTO_POLY1305_MIPS - tristate "Hash functions: Poly1305" + tristate depends on MIPS + select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -52,7 +53,7 @@ config CRYPTO_SHA512_OCTEON Architecture: mips OCTEON using crypto instructions, when available config CRYPTO_CHACHA_MIPS - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)" + tristate depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index e453cb0c82d2..589ae680a272 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (powerpc)" config CRYPTO_CURVE25519_PPC64 - tristate "Public key crypto: Curve25519 (PowerPC64)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -91,11 +91,10 @@ config CRYPTO_AES_GCM_P10 later CPU. This module supports stitched acceleration for AES/GCM. config CRYPTO_CHACHA20_P10 - tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index ad58dad9a580..c67095a3d669 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -22,7 +22,6 @@ config CRYPTO_CHACHA_RISCV64 tristate "Ciphers: ChaCha" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC help Length-preserving ciphers: ChaCha20 stream cipher algorithm diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index b760232537f1..c327aeccfde7 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -108,10 +108,9 @@ config CRYPTO_DES_S390 As of z196 the CTR mode is hardware accelerated. config CRYPTO_CHACHA_S390 - tristate "Ciphers: ChaCha20" + tristate depends on S390 select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index c189dad0969b..725105919cd3 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (x86)" config CRYPTO_CURVE25519_X86 - tristate "Public key crypto: Curve25519 (ADX)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -348,11 +348,10 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64 Processes 64 blocks in parallel. config CRYPTO_CHACHA20_X86_64 - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)" + tristate depends on X86 && 64BIT select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -417,10 +416,10 @@ config CRYPTO_POLYVAL_CLMUL_NI - CLMUL-NI (carry-less multiplication new instructions) config CRYPTO_POLY1305_X86_64 - tristate "Hash functions: Poly1305 (SSE2/AVX2)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_POLY1305_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_HASH + select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index c542ef1d64d0..f095df82f5e9 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -48,11 +48,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA accelerated implementation of the ChaCha library interface, 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 tristate select CRYPTO_LIB_UTILS @@ -65,7 +60,13 @@ config CRYPTO_LIB_CHACHA_GENERIC config CRYPTO_LIB_CHACHA tristate "ChaCha library interface" + select CRYPTO select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n + select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT + select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) + select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 + select CRYPTO_CHACHA_S390 if S390 + select CRYPTO_CHACHA20_P10 if PPC64 && CPU_LITTLE_ENDIAN && VSX help Enable the ChaCha library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -78,13 +79,9 @@ config CRYPTO_ARCH_HAVE_LIB_CURVE25519 accelerated implementation of the Curve25519 library interface, 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 tristate + select CRYPTO_LIB_UTILS help This symbol can be depended upon by arch implementations of the Curve25519 library interface that require the generic code as a @@ -95,7 +92,9 @@ config CRYPTO_LIB_CURVE25519_GENERIC config CRYPTO_LIB_CURVE25519 tristate "Curve25519 scalar multiplication library" select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n - select CRYPTO_LIB_UTILS + select CRYPTO_CURVE25519_X86 if X86 && 64BIT + select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON + select CRYPTO_CURVE25519_PPC64 if PPC64 && CPU_LITTLE_ENDIAN help Enable the Curve25519 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific @@ -118,11 +117,6 @@ config CRYPTO_ARCH_HAVE_LIB_POLY1305 accelerated implementation of the Poly1305 library interface, 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 tristate help @@ -135,6 +129,10 @@ config CRYPTO_LIB_POLY1305_GENERIC config CRYPTO_LIB_POLY1305 tristate "Poly1305 library interface" select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n + select CRYPTO_POLY1305_X86_64 if X86 && 64BIT + select CRYPTO_POLY1305_NEON if ARM64 && KERNEL_MODE_NEON + select CRYPTO_POLY1305_ARM if ARM + select CRYPTO_POLY1305_MIPS if MIPS help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -142,9 +140,10 @@ config CRYPTO_LIB_POLY1305 config CRYPTO_LIB_CHACHA20POLY1305 tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)" - depends on CRYPTO + select CRYPTO select CRYPTO_LIB_CHACHA select CRYPTO_LIB_POLY1305 + select CRYPTO_LIB_UTILS select CRYPTO_ALGAPI config CRYPTO_LIB_SHA1 -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - Select and hide arch options 2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu @ 2025-02-26 6:07 ` Eric Biggers 2025-02-26 8:31 ` Herbert Xu 2025-02-26 9:08 ` [v2 PATCH] crypto: lib/Kconfig - Hide arch options from user Herbert Xu ` (2 subsequent siblings) 3 siblings, 1 reply; 17+ messages in thread From: Eric Biggers @ 2025-02-26 6:07 UTC (permalink / raw) To: Herbert Xu Cc: Arnd Bergmann, Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Wed, Feb 26, 2025 at 12:36:33PM +0800, Herbert Xu wrote: > 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. > > 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> As I said earlier, fixing the arch-optimized code to be enabled automatically is the right way to do it. There are still some issues with this patch, though: > config CRYPTO_LIB_CHACHA > tristate "ChaCha library interface" > + select CRYPTO > select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n > + select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT > + select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) > + select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 > + select CRYPTO_CHACHA_S390 if S390 > + select CRYPTO_CHACHA20_P10 if PPC64 && CPU_LITTLE_ENDIAN && VSX There's no need to have a select for every architecture, with the dependencies redundantly listed. Instead just 'default' each of the arch-optimized options to CRYPTO_LIB_CHACHA. > config CRYPTO_CHACHA20_X86_64 > tristate > depends on X86 && 64BIT > default CRYPTO_CHACHA20 > select CRYPTO_ARCH_HAVE_LIB_CHACHA [...] > > config CRYPTO_CHACHA20 > tristate "ChaCha" > select CRYPTO_LIB_CHACHA_GENERIC > select CRYPTO_SKCIPHER This introduces a problem where to enable optimized ChaCha in the crypto API users will now need to enable CRYPTO_LIB_CHACHA, instead of CRYPTO_CHACHA20_X86_64 etc. as was needed before. LIB symbols should never be user-selectable, so that makes no sense. The way it should work is that CRYPTO_CHACHA20 should just select CRYPTO_LIB_CHACHA (and thus also the optimized code). And similarly for the other algorithms, which should be in their patches. - Eric ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - Select and hide arch options 2025-02-26 6:07 ` Eric Biggers @ 2025-02-26 8:31 ` Herbert Xu 0 siblings, 0 replies; 17+ messages in thread From: Herbert Xu @ 2025-02-26 8:31 UTC (permalink / raw) To: Eric Biggers Cc: Arnd Bergmann, Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Tue, Feb 25, 2025 at 10:07:25PM -0800, Eric Biggers wrote: > > There's no need to have a select for every architecture, with the dependencies > redundantly listed. Instead just 'default' each of the arch-optimized options > to CRYPTO_LIB_CHACHA. Good point. > The way it should work is that CRYPTO_CHACHA20 should just select > CRYPTO_LIB_CHACHA (and thus also the optimized code). Good catch. I'll add them. > And similarly for the other algorithms, which should be in their patches. It's best to keep everything together as if done separately they may introduce bisection issues between the patches. Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 17+ messages in thread
* [v2 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu 2025-02-26 6:07 ` Eric Biggers @ 2025-02-26 9:08 ` Herbert Xu 2025-02-27 7:48 ` [v3 " Herbert Xu 2025-02-27 5:57 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options kernel test robot 2025-02-27 6:29 ` kernel test robot 3 siblings, 1 reply; 17+ messages in thread From: Herbert Xu @ 2025-02-26 9:08 UTC (permalink / raw) To: Arnd Bergmann Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 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> diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 47d9cc59f254..0c19317a9ce0 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -3,10 +3,11 @@ menu "Accelerated Cryptographic Algorithms for CPU (arm)" config CRYPTO_CURVE25519_NEON - tristate "Public key crypto: Curve25519 (NEON)" + tristate depends on KERNEL_MODE_NEON - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -45,9 +46,10 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_ARM - tristate "Hash functions: Poly1305 (NEON)" + tristate select CRYPTO_HASH - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -212,9 +214,10 @@ config CRYPTO_AES_ARM_CE - ARMv8 Crypto Extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" + tristate select CRYPTO_SKCIPHER - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 5636ab83f22a..1b14551cc301 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -26,10 +26,11 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_NEON - tristate "Hash functions: Poly1305 (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -186,11 +187,11 @@ config CRYPTO_AES_ARM64_NEON_BLK - NEON (Advanced SIMD) extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 7decd40c4e20..545fc0e12422 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -3,9 +3,11 @@ menu "Accelerated Cryptographic Algorithms for CPU (mips)" config CRYPTO_POLY1305_MIPS - tristate "Hash functions: Poly1305" + tristate depends on MIPS + select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -52,10 +54,11 @@ config CRYPTO_SHA512_OCTEON Architecture: mips OCTEON using crypto instructions, when available config CRYPTO_CHACHA_MIPS - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)" + tristate depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index e453cb0c82d2..5beed03869c9 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -3,10 +3,11 @@ menu "Accelerated Cryptographic Algorithms for CPU (powerpc)" config CRYPTO_CURVE25519_PPC64 - tristate "Public key crypto: Curve25519 (PowerPC64)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -91,11 +92,11 @@ config CRYPTO_AES_GCM_P10 later CPU. This module supports stitched acceleration for AES/GCM. config CRYPTO_CHACHA20_P10 - tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index ad58dad9a580..c67095a3d669 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -22,7 +22,6 @@ config CRYPTO_CHACHA_RISCV64 tristate "Ciphers: ChaCha" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC help Length-preserving ciphers: ChaCha20 stream cipher algorithm diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index b760232537f1..f6f82dab3594 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -108,11 +108,11 @@ config CRYPTO_DES_S390 As of z196 the CTR mode is hardware accelerated. config CRYPTO_CHACHA_S390 - tristate "Ciphers: ChaCha20" + tristate depends on S390 select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index c189dad0969b..d3128e99bac5 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -3,10 +3,11 @@ menu "Accelerated Cryptographic Algorithms for CPU (x86)" config CRYPTO_CURVE25519_X86 - tristate "Public key crypto: Curve25519 (ADX)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -348,11 +349,11 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64 Processes 64 blocks in parallel. config CRYPTO_CHACHA20_X86_64 - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)" + tristate depends on X86 && 64BIT select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -417,10 +418,11 @@ config CRYPTO_POLYVAL_CLMUL_NI - CLMUL-NI (carry-less multiplication new instructions) config CRYPTO_POLY1305_X86_64 - tristate "Hash functions: Poly1305 (SSE2/AVX2)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_POLY1305_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_HASH + select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) diff --git a/crypto/Kconfig b/crypto/Kconfig index 74ae5f52b784..b7771d7bd3b3 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -317,7 +317,7 @@ config CRYPTO_ECRDSA config CRYPTO_CURVE25519 tristate "Curve25519" select CRYPTO_KPP - select CRYPTO_LIB_CURVE25519_GENERIC + select CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 elliptic curve (RFC7748) @@ -615,7 +615,7 @@ config CRYPTO_ARC4 config CRYPTO_CHACHA20 tristate "ChaCha" - select CRYPTO_LIB_CHACHA_GENERIC + select CRYPTO_LIB_CHACHA_INTERNAL select CRYPTO_SKCIPHER help The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -936,7 +936,7 @@ config CRYPTO_POLYVAL config CRYPTO_POLY1305 tristate "Poly1305" select CRYPTO_HASH - select CRYPTO_LIB_POLY1305_GENERIC + select CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index c542ef1d64d0..b09e78da959a 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -48,11 +48,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA accelerated implementation of the ChaCha library interface, 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 tristate select CRYPTO_LIB_UTILS @@ -63,9 +58,14 @@ config CRYPTO_LIB_CHACHA_GENERIC implementation is enabled, this implementation serves the users 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 tristate "ChaCha library interface" - select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n + select CRYPTO + select CRYPTO_LIB_CHACHA_INTERNAL help Enable the ChaCha library interface. This interface may be fulfilled 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, 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 tristate + select CRYPTO_LIB_UTILS help This symbol can be depended upon by arch implementations of the 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 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 tristate "Curve25519 scalar multiplication library" - select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n - select CRYPTO_LIB_UTILS + select CRYPTO + select CRYPTO_LIB_CURVE25519_INTERNAL help Enable the Curve25519 library interface. This interface may be 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, 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 tristate help @@ -132,9 +127,14 @@ config CRYPTO_LIB_POLY1305_GENERIC implementation is enabled, this implementation serves the users 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 tristate "Poly1305 library interface" - select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n + select CRYPTO + select CRYPTO_LIB_POLY1305_INTERNAL help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -142,9 +142,10 @@ config CRYPTO_LIB_POLY1305 config CRYPTO_LIB_CHACHA20POLY1305 tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)" - depends on CRYPTO + select CRYPTO select CRYPTO_LIB_CHACHA select CRYPTO_LIB_POLY1305 + select CRYPTO_LIB_UTILS select CRYPTO_ALGAPI config CRYPTO_LIB_SHA1 -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-26 9:08 ` [v2 PATCH] crypto: lib/Kconfig - Hide arch options from user Herbert Xu @ 2025-02-27 7:48 ` Herbert Xu 2025-02-27 8:32 ` Arnd Bergmann 0 siblings, 1 reply; 17+ messages in thread From: Herbert Xu @ 2025-02-27 7:48 UTC (permalink / raw) To: Arnd Bergmann Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 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> diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 47d9cc59f254..23e4ea067ddb 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -3,10 +3,12 @@ menu "Accelerated Cryptographic Algorithms for CPU (arm)" config CRYPTO_CURVE25519_NEON - tristate "Public key crypto: Curve25519 (NEON)" + tristate depends on KERNEL_MODE_NEON + select CRYPTO_KPP select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -45,9 +47,10 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_ARM - tristate "Hash functions: Poly1305 (NEON)" + tristate select CRYPTO_HASH - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -212,9 +215,10 @@ config CRYPTO_AES_ARM_CE - ARMv8 Crypto Extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" + tristate select CRYPTO_SKCIPHER - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 5636ab83f22a..3418c8d3c78d 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -26,10 +26,11 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_NEON - tristate "Hash functions: Poly1305 (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -186,11 +187,12 @@ config CRYPTO_AES_ARM64_NEON_BLK - NEON (Advanced SIMD) extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 7decd40c4e20..545fc0e12422 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -3,9 +3,11 @@ menu "Accelerated Cryptographic Algorithms for CPU (mips)" config CRYPTO_POLY1305_MIPS - tristate "Hash functions: Poly1305" + tristate depends on MIPS + select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) @@ -52,10 +54,11 @@ config CRYPTO_SHA512_OCTEON Architecture: mips OCTEON using crypto instructions, when available config CRYPTO_CHACHA_MIPS - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)" + tristate depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index e453cb0c82d2..370db8192ce6 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -3,10 +3,12 @@ menu "Accelerated Cryptographic Algorithms for CPU (powerpc)" config CRYPTO_CURVE25519_PPC64 - tristate "Public key crypto: Curve25519 (PowerPC64)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN + select CRYPTO_KPP select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -91,11 +93,12 @@ config CRYPTO_AES_GCM_P10 later CPU. This module supports stitched acceleration for AES/GCM. config CRYPTO_CHACHA20_P10 - tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index ad58dad9a580..c67095a3d669 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -22,7 +22,6 @@ config CRYPTO_CHACHA_RISCV64 tristate "Ciphers: ChaCha" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC help Length-preserving ciphers: ChaCha20 stream cipher algorithm diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index b760232537f1..8c4db8b64fa2 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -108,11 +108,12 @@ config CRYPTO_DES_S390 As of z196 the CTR mode is hardware accelerated. config CRYPTO_CHACHA_S390 - tristate "Ciphers: ChaCha20" + tristate depends on S390 select CRYPTO_SKCIPHER select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index c189dad0969b..3d948f10c94c 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -3,10 +3,12 @@ menu "Accelerated Cryptographic Algorithms for CPU (x86)" config CRYPTO_CURVE25519_X86 - tristate "Public key crypto: Curve25519 (ADX)" + tristate depends on X86 && 64BIT + select CRYPTO_KPP select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 + default CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 algorithm @@ -348,11 +350,12 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64 Processes 64 blocks in parallel. config CRYPTO_CHACHA20_X86_64 - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)" + tristate depends on X86 && 64BIT select CRYPTO_SKCIPHER select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA + default CRYPTO_LIB_CHACHA_INTERNAL help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -417,10 +420,12 @@ config CRYPTO_POLYVAL_CLMUL_NI - CLMUL-NI (carry-less multiplication new instructions) config CRYPTO_POLY1305_X86_64 - tristate "Hash functions: Poly1305 (SSE2/AVX2)" + tristate depends on X86 && 64BIT + select CRYPTO_HASH select CRYPTO_LIB_POLY1305_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_ARCH_HAVE_LIB_POLY1305 + default CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) diff --git a/crypto/Kconfig b/crypto/Kconfig index 74ae5f52b784..b7771d7bd3b3 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -317,7 +317,7 @@ config CRYPTO_ECRDSA config CRYPTO_CURVE25519 tristate "Curve25519" select CRYPTO_KPP - select CRYPTO_LIB_CURVE25519_GENERIC + select CRYPTO_LIB_CURVE25519_INTERNAL help Curve25519 elliptic curve (RFC7748) @@ -615,7 +615,7 @@ config CRYPTO_ARC4 config CRYPTO_CHACHA20 tristate "ChaCha" - select CRYPTO_LIB_CHACHA_GENERIC + select CRYPTO_LIB_CHACHA_INTERNAL select CRYPTO_SKCIPHER help The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -936,7 +936,7 @@ config CRYPTO_POLYVAL config CRYPTO_POLY1305 tristate "Poly1305" select CRYPTO_HASH - select CRYPTO_LIB_POLY1305_GENERIC + select CRYPTO_LIB_POLY1305_INTERNAL help Poly1305 authenticator algorithm (RFC7539) diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index c542ef1d64d0..b09e78da959a 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -48,11 +48,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA accelerated implementation of the ChaCha library interface, 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 tristate select CRYPTO_LIB_UTILS @@ -63,9 +58,14 @@ config CRYPTO_LIB_CHACHA_GENERIC implementation is enabled, this implementation serves the users 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 tristate "ChaCha library interface" - select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n + select CRYPTO + select CRYPTO_LIB_CHACHA_INTERNAL help Enable the ChaCha library interface. This interface may be fulfilled 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, 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 tristate + select CRYPTO_LIB_UTILS help This symbol can be depended upon by arch implementations of the 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 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 tristate "Curve25519 scalar multiplication library" - select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n - select CRYPTO_LIB_UTILS + select CRYPTO + select CRYPTO_LIB_CURVE25519_INTERNAL help Enable the Curve25519 library interface. This interface may be 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, 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 tristate help @@ -132,9 +127,14 @@ config CRYPTO_LIB_POLY1305_GENERIC implementation is enabled, this implementation serves the users 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 tristate "Poly1305 library interface" - select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n + select CRYPTO + select CRYPTO_LIB_POLY1305_INTERNAL help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -142,9 +142,10 @@ config CRYPTO_LIB_POLY1305 config CRYPTO_LIB_CHACHA20POLY1305 tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)" - depends on CRYPTO + select CRYPTO select CRYPTO_LIB_CHACHA select CRYPTO_LIB_POLY1305 + select CRYPTO_LIB_UTILS select CRYPTO_ALGAPI config CRYPTO_LIB_SHA1 -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-27 7:48 ` [v3 " Herbert Xu @ 2025-02-27 8:32 ` Arnd Bergmann 2025-02-27 8:43 ` Herbert Xu 0 siblings, 1 reply; 17+ messages in thread From: Arnd Bergmann @ 2025-02-27 8:32 UTC (permalink / raw) To: Herbert Xu, Arnd Bergmann Cc: Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Thu, Feb 27, 2025, at 08:48, Herbert Xu wrote: > 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> This looks like a good approach. Once it works correctly, it should be possible to clean up the 'select' statements in wireguard as well and just 'select CRYPTO_LIB_CHACHA' etc. > @@ -45,9 +47,10 @@ config CRYPTO_NHPOLY1305_NEON > - NEON (Advanced SIMD) extensions > > config CRYPTO_POLY1305_ARM > - tristate "Hash functions: Poly1305 (NEON)" > + tristate > select CRYPTO_HASH > - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 > + select CRYPTO_ARCH_HAVE_LIB_POLY1305 > + default CRYPTO_LIB_POLY1305_INTERNAL > help > Poly1305 authenticator algorithm (RFC7539) > > @@ -212,9 +215,10 @@ config CRYPTO_AES_ARM_CE > - ARMv8 Crypto Extensions > > config CRYPTO_CHACHA20_NEON > - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" > + tristate > select CRYPTO_SKCIPHER > - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA > + select CRYPTO_ARCH_HAVE_LIB_CHACHA > + default CRYPTO_LIB_CHACHA_INTERNAL I think the more common style is to put the 'default' lines before 'select'. It appears that the two above are missing a 'depends on KERNEL_MODE_NEON' line. There is still a runtime check that prevents it from being used on non-neon machines, but I think you should add these lines here since it's no longer possible to turn them off individually when building a kernel for a non-NEON target. > +config CRYPTO_LIB_CHACHA_INTERNAL > + tristate > + select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n > + > config CRYPTO_LIB_CHACHA > tristate "ChaCha library interface" > - select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n > + select CRYPTO > + select CRYPTO_LIB_CHACHA_INTERNAL > help > Enable the ChaCha library interface. This interface may be fulfilled > by either the generic implementation or an arch-specific one, if one I'm not sure why we need the extra "_INTERNAL" symbols, but I may be missing something here. What problem does this solve for you? Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-27 8:32 ` Arnd Bergmann @ 2025-02-27 8:43 ` Herbert Xu 2025-02-27 11:56 ` Arnd Bergmann 0 siblings, 1 reply; 17+ messages in thread From: Herbert Xu @ 2025-02-27 8:43 UTC (permalink / raw) To: Arnd Bergmann Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Thu, Feb 27, 2025 at 09:32:51AM +0100, Arnd Bergmann wrote: > > This looks like a good approach. Once it works correctly, > it should be possible to clean up the 'select' statements > in wireguard as well and just 'select CRYPTO_LIB_CHACHA' etc. Yes that's the idea. > I think the more common style is to put the 'default' > lines before 'select'. It is the customary place in the crypto tree. > It appears that the two above are missing a > 'depends on KERNEL_MODE_NEON' line. There is still > a runtime check that prevents it from being used on > non-neon machines, but I think you should add these > lines here since it's no longer possible to turn > them off individually when building a kernel for a > non-NEON target. Good catch. But I think this was deliberate as it also includes a non-NEON implementation: commit b36d8c09e710c71f6a9690b6586fea2d1c9e1e27 Author: Ard Biesheuvel <ardb@kernel.org> Date: Fri Nov 8 13:22:14 2019 +0100 crypto: arm/chacha - remove dependency on generic ChaCha driver Instead of falling back to the generic ChaCha skcipher driver for non-SIMD cases, use a fast scalar implementation for ARM authored by Eric Biggers. This removes the module dependency on chacha-generic altogether, which also simplifies things when we expose the ChaCha library interface from this module. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > I'm not sure why we need the extra "_INTERNAL" symbols, but I > may be missing something here. What problem does this solve > for you? Without them Kconfig will bomb out because of a loop centering on CONFIG_CRYPTO. Cheers, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-27 8:43 ` Herbert Xu @ 2025-02-27 11:56 ` Arnd Bergmann 2025-02-27 12:04 ` Ard Biesheuvel [not found] ` <Z8E3gjfvG3eFoLxR@gondor.apana.org.au> 0 siblings, 2 replies; 17+ messages in thread From: Arnd Bergmann @ 2025-02-27 11:56 UTC (permalink / raw) To: Herbert Xu Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Thu, Feb 27, 2025, at 09:43, Herbert Xu wrote: > On Thu, Feb 27, 2025 at 09:32:51AM +0100, Arnd Bergmann wrote: >> It appears that the two above are missing a >> 'depends on KERNEL_MODE_NEON' line. There is still >> a runtime check that prevents it from being used on >> non-neon machines, but I think you should add these >> lines here since it's no longer possible to turn >> them off individually when building a kernel for a >> non-NEON target. > > Good catch. But I think this was deliberate as it also includes > a non-NEON implementation: > > commit b36d8c09e710c71f6a9690b6586fea2d1c9e1e27 > Author: Ard Biesheuvel <ardb@kernel.org> > Date: Fri Nov 8 13:22:14 2019 +0100 > > crypto: arm/chacha - remove dependency on generic ChaCha driver Ah, I see. That's fine then. > Instead of falling back to the generic ChaCha skcipher driver for > non-SIMD cases, use a fast scalar implementation for ARM authored > by Eric Biggers. This removes the module dependency on chacha-generic > altogether, which also simplifies things when we expose the ChaCha > library interface from this module. > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > >> I'm not sure why we need the extra "_INTERNAL" symbols, but I >> may be missing something here. What problem does this solve >> for you? > > Without them Kconfig will bomb out because of a loop centering > on CONFIG_CRYPTO. I've tried to undo that portion here and don't run into a dependency loop so far with the patch below on top of yours (around 100 randconfigs in). I'll keep testing and will let you know when something goes wrong. One issue I've already found in your version is that removing the 'select CRYPTO_LIB_CHACHA_GENERIC' is broken in the majority of the cases where an architecture specific implementation is enabled, because the architecture code typically contains a fallback to the generic version for the case where the custom CPU instructions are not present. I've added the 'select' lines to the architecture versions here, but since it's almost always needed, we could decide to just leave the generic version built-in anyway to make it less error-prone at the cost of kernel bloat in the few cases where it's not used. An unrelated issue I noticed is that CRYPTO_LIB_CHACHA20POLY1305 depends on CRYPTO in order to pull in CRYPTO_ALGAPI, this looks like a mistake and could be resolved by moving crypto/scatterwalk.c into lib/crypto/ with its own symbol. That should be a separate patch of course. Arnd diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 0c19317a9ce0..f2e3b62c1379 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_NEON depends on KERNEL_MODE_NEON select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -49,7 +50,8 @@ config CRYPTO_POLY1305_ARM tristate select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -217,7 +219,8 @@ config CRYPTO_CHACHA20_NEON tristate select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 1b14551cc301..17f447240f9a 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -30,7 +30,7 @@ config CRYPTO_POLY1305_NEON depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -191,7 +191,8 @@ config CRYPTO_CHACHA20_NEON depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 545fc0e12422..e0d8ee2677df 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -7,7 +7,7 @@ config CRYPTO_POLY1305_MIPS depends on MIPS select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -58,7 +58,7 @@ config CRYPTO_CHACHA_MIPS depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index 5beed03869c9..49f929f49e45 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_PPC64 depends on PPC64 && CPU_LITTLE_ENDIAN select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -96,7 +97,8 @@ config CRYPTO_CHACHA20_P10 depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index f6f82dab3594..13245d569d4d 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -112,7 +112,8 @@ config CRYPTO_CHACHA_S390 depends on S390 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index d3128e99bac5..1f20425f6c87 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_X86 depends on X86 && 64BIT select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -353,7 +354,8 @@ config CRYPTO_CHACHA20_X86_64 depends on X86 && 64BIT select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -422,7 +424,8 @@ config CRYPTO_POLY1305_X86_64 depends on X86 && 64BIT select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) diff --git a/crypto/Kconfig b/crypto/Kconfig index aac27a4668fd..6013850c114c 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -317,7 +317,7 @@ config CRYPTO_ECRDSA config CRYPTO_CURVE25519 tristate "Curve25519" select CRYPTO_KPP - select CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519 help Curve25519 elliptic curve (RFC7748) @@ -615,7 +615,7 @@ config CRYPTO_ARC4 config CRYPTO_CHACHA20 tristate "ChaCha" - select CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA select CRYPTO_SKCIPHER help The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -936,7 +936,7 @@ config CRYPTO_POLYVAL config CRYPTO_POLY1305 tristate "Poly1305" select CRYPTO_HASH - select CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC help Poly1305 authenticator algorithm (RFC7539) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 1fd5acdc73c6..417b691c7c53 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -82,18 +82,6 @@ config WIREGUARD select CRYPTO select CRYPTO_LIB_CURVE25519 select CRYPTO_LIB_CHACHA20POLY1305 - select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT - select CRYPTO_POLY1305_X86_64 if X86 && 64BIT - select CRYPTO_BLAKE2S_X86 if X86 && 64BIT - select CRYPTO_CURVE25519_X86 if X86 && 64BIT - select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) - select CRYPTO_POLY1305_NEON if ARM64 && KERNEL_MODE_NEON - select CRYPTO_POLY1305_ARM if ARM - select CRYPTO_BLAKE2S_ARM if ARM - select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON - select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 - select CRYPTO_POLY1305_MIPS if MIPS - select CRYPTO_CHACHA_S390 if S390 help WireGuard is a secure, fast, and easy to use replacement for IPSec that uses modern cryptography and clever networking tricks. It's diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index b09e78da959a..8fdb1a5de909 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -42,7 +42,7 @@ config CRYPTO_LIB_BLAKE2S_GENERIC of CRYPTO_LIB_BLAKE2S. config CRYPTO_ARCH_HAVE_LIB_CHACHA - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the ChaCha library interface, @@ -58,21 +58,16 @@ config CRYPTO_LIB_CHACHA_GENERIC implementation is enabled, this implementation serves the users 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 tristate "ChaCha library interface" - select CRYPTO - select CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n help Enable the ChaCha library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one is available and enabled. config CRYPTO_ARCH_HAVE_LIB_CURVE25519 - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the Curve25519 library interface, @@ -88,14 +83,9 @@ config CRYPTO_LIB_CURVE25519_GENERIC implementation is enabled, this implementation serves the users 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 tristate "Curve25519 scalar multiplication library" - select CRYPTO - select CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n help Enable the Curve25519 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific @@ -112,7 +102,7 @@ config CRYPTO_LIB_POLY1305_RSIZE default 1 config CRYPTO_ARCH_HAVE_LIB_POLY1305 - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the Poly1305 library interface, @@ -127,14 +117,9 @@ config CRYPTO_LIB_POLY1305_GENERIC implementation is enabled, this implementation serves the users 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 tristate "Poly1305 library interface" - select CRYPTO - select CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user 2025-02-27 11:56 ` Arnd Bergmann @ 2025-02-27 12:04 ` Ard Biesheuvel [not found] ` <Z8E3gjfvG3eFoLxR@gondor.apana.org.au> 1 sibling, 0 replies; 17+ messages in thread From: Ard Biesheuvel @ 2025-02-27 12:04 UTC (permalink / raw) To: Arnd Bergmann Cc: Herbert Xu, Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Thu, 27 Feb 2025 at 12:57, Arnd Bergmann <arnd@arndb.de> wrote: > .. > > An unrelated issue I noticed is that CRYPTO_LIB_CHACHA20POLY1305 > depends on CRYPTO in order to pull in CRYPTO_ALGAPI, this > looks like a mistake and could be resolved by moving > crypto/scatterwalk.c into lib/crypto/ with its own symbol. > That should be a separate patch of course. > The only use of the scatterwalk API in lib/crypto is from chacha20poly1305_crypt_sg_inplace(), and it occurs on a cold path where the digest buffer is covered by a separate scatterlist entry. I'll look into whether we could just use the sg_miter API there instead, which is what the rest of the code already uses. ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <Z8E3gjfvG3eFoLxR@gondor.apana.org.au>]
* Re: [v3 PATCH] crypto: lib/Kconfig - Hide arch options from user [not found] ` <Z8E3gjfvG3eFoLxR@gondor.apana.org.au> @ 2025-02-28 17:10 ` Arnd Bergmann 0 siblings, 0 replies; 17+ messages in thread From: Arnd Bergmann @ 2025-02-28 17:10 UTC (permalink / raw) To: Herbert Xu Cc: Arnd Bergmann, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 On Fri, Feb 28, 2025, at 05:11, Herbert Xu wrote: > On Thu, Feb 27, 2025 at 12:56:30PM +0100, Arnd Bergmann wrote: >> >> I've tried to undo that portion here and don't run into a >> dependency loop so far with the patch below on top of yours >> (around 100 randconfigs in). I'll keep testing and will let >> you know when something goes wrong. > > That's because you removed 'select CRYPTO', which can cause the > arch code to silently disappear just like my original patch. > > It's pretty much difficult to disable CRYPTO because so many > random things select it. But I managed to turn CRYPTO off with > some effort and indeed with your patch the arch code disappears. > > In the following config file, CONFIG_CRYPTO_LIB_CHACHA is modular but > the X86 option for it is not selected, because CRYPTO itself is off. I see. So the case of building lib/crypto code but not CONFIG_CRYPTO is something I would normally expect to work, including the architecture specific optimizations, and it's probably not too hard to get there, but it's also unclear if there is really a point in doing that. For design purity, I think we would need to split the architecture specific code the same way as the generic ones: library functions that always get selected by their users to export functions and the front-ends that are user-selectable and register the algorithm with the crypto API. Keeping the 'select CRYPTO' is clearly less effor if you prefer that. Arnd ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - Select and hide arch options 2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu 2025-02-26 6:07 ` Eric Biggers 2025-02-26 9:08 ` [v2 PATCH] crypto: lib/Kconfig - Hide arch options from user Herbert Xu @ 2025-02-27 5:57 ` kernel test robot 2025-02-27 6:29 ` kernel test robot 3 siblings, 0 replies; 17+ messages in thread From: kernel test robot @ 2025-02-27 5:57 UTC (permalink / raw) To: Herbert Xu, Arnd Bergmann Cc: oe-kbuild-all, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 Hi Herbert, kernel test robot noticed the following build errors: [auto build test ERROR on herbert-cryptodev-2.6/master] [also build test ERROR on next-20250226] [cannot apply to soc/for-next linus/master v6.14-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-lib-Kconfig-Select-and-hide-arch-options/20250226-125220 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/Z76aUfPIbhPAsHbv%40gondor.apana.org.au patch subject: [PATCH] crypto: lib/Kconfig - Select and hide arch options config: s390-randconfig-002-20250227 (https://download.01.org/0day-ci/archive/20250227/202502271317.S0YZiPk1-lkp@intel.com/config) compiler: s390-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250227/202502271317.S0YZiPk1-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202502271317.S0YZiPk1-lkp@intel.com/ All errors (new ones prefixed by >>): s390-linux-ld: arch/s390/crypto/chacha-glue.o: in function `chacha20_s390': >> chacha-glue.c:(.text+0x30e): undefined reference to `chacha_crypt_generic' s390-linux-ld: arch/s390/crypto/chacha-glue.o: in function `chacha_crypt_arch': chacha-glue.c:(.text+0x3f6): undefined reference to `chacha_crypt_generic' -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] crypto: lib/Kconfig - Select and hide arch options 2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu ` (2 preceding siblings ...) 2025-02-27 5:57 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options kernel test robot @ 2025-02-27 6:29 ` kernel test robot 3 siblings, 0 replies; 17+ messages in thread From: kernel test robot @ 2025-02-27 6:29 UTC (permalink / raw) To: Herbert Xu, Arnd Bergmann Cc: llvm, oe-kbuild-all, Will Deacon, David S . Miller, Catalin Marinas, Thomas Bogendoerfer, Harald Freudenberger, Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Martin K. Petersen, Ard Biesheuvel, Eric Biggers, James E . J . Bottomley, Jarkko Sakkinen, linux-crypto, linux-arm-kernel, linux-kernel, linux-mips, linux-s390 Hi Herbert, kernel test robot noticed the following build errors: [auto build test ERROR on herbert-cryptodev-2.6/master] [cannot apply to soc/for-next linus/master v6.14-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-lib-Kconfig-Select-and-hide-arch-options/20250226-125220 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/Z76aUfPIbhPAsHbv%40gondor.apana.org.au patch subject: [PATCH] crypto: lib/Kconfig - Select and hide arch options config: x86_64-buildonly-randconfig-002-20250227 (https://download.01.org/0day-ci/archive/20250227/202502271449.k2LZdEgF-lkp@intel.com/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250227/202502271449.k2LZdEgF-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202502271449.k2LZdEgF-lkp@intel.com/ All errors (new ones prefixed by >>, old ones prefixed by <<): WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-mgr-test.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-bridge-test.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-region-test.o >> ERROR: modpost: "curve25519_generic" [arch/x86/crypto/curve25519-x86_64.ko] undefined! >> ERROR: modpost: "curve25519_base_point" [arch/x86/crypto/curve25519-x86_64.ko] undefined! >> ERROR: modpost: "curve25519_null_point" [arch/x86/crypto/curve25519-x86_64.ko] undefined! >> ERROR: modpost: "curve25519_null_point" [lib/crypto/libcurve25519.ko] undefined! >> ERROR: modpost: "curve25519_generic" [lib/crypto/libcurve25519.ko] undefined! -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-02-28 17:16 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 16:42 [PATCH] crypto: lib/Kconfig - fix chacha/poly1305 dependencies more more Arnd Bergmann
2025-02-25 21:33 ` Will Deacon
2025-02-25 21:40 ` Arnd Bergmann
2025-02-25 21:50 ` Arnd Bergmann
2025-02-26 1:40 ` Herbert Xu
2025-02-26 4:36 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options Herbert Xu
2025-02-26 6:07 ` Eric Biggers
2025-02-26 8:31 ` Herbert Xu
2025-02-26 9:08 ` [v2 PATCH] crypto: lib/Kconfig - Hide arch options from user Herbert Xu
2025-02-27 7:48 ` [v3 " Herbert Xu
2025-02-27 8:32 ` Arnd Bergmann
2025-02-27 8:43 ` Herbert Xu
2025-02-27 11:56 ` Arnd Bergmann
2025-02-27 12:04 ` Ard Biesheuvel
[not found] ` <Z8E3gjfvG3eFoLxR@gondor.apana.org.au>
2025-02-28 17:10 ` Arnd Bergmann
2025-02-27 5:57 ` [PATCH] crypto: lib/Kconfig - Select and hide arch options kernel test robot
2025-02-27 6:29 ` kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).