public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: fix dependencies on lib/crypto modules
@ 2025-03-10 13:26 Arnd Bergmann
  2025-03-10 13:26 ` [PATCH 2/2] crypto: lib/Kconfig: hide library options Arnd Bergmann
  2025-03-10 17:24 ` [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Eric Biggers
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-03-10 13:26 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: Arnd Bergmann, Ard Biesheuvel, Eric Biggers, Lukas Wunner,
	Stephan Mueller, linux-crypto, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The crypto subsystem helpers for chacha, poly1305 and curve25519 were
changed to select the 'INTERNAL' Kconfig symbols, but the code references
the generic implementation instead, which leads to a link failure when
nothing else selects it.

ld.lld-21: error: undefined symbol: chacha_crypt_generic
>>> referenced by chacha_generic.c
>>>               crypto/chacha_generic.o:(chacha_stream_xor) in archive vmlinux.a

ld.lld-21: error: undefined symbol: poly1305_final_generic
>>> referenced by poly1305_generic.c
>>>               crypto/poly1305_generic.o:(crypto_poly1305_final) in archive vmlinux.a

The INTERNAL version turns on the architecture specific optimized cipher,
which normally usually also enables the generic version, but this is not
the case on all architectures. Selecting only the GENERIC version here is
not sufficient since the architecture specific ones are now hidden symbols
and are only built when the INTERNAL symbol is also available.

Fixes: 17ec3e71ba79 ("crypto: lib/Kconfig - Hide arch options from user")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 crypto/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index aac27a4668fd..76693e3edff8 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -317,6 +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,6 +616,7 @@ config CRYPTO_ARC4
 
 config CRYPTO_CHACHA20
 	tristate "ChaCha"
+	select CRYPTO_LIB_CHACHA_GENERIC
 	select CRYPTO_LIB_CHACHA_INTERNAL
 	select CRYPTO_SKCIPHER
 	help
@@ -936,6 +938,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)
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] crypto: lib/Kconfig: hide library options
  2025-03-10 13:26 [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Arnd Bergmann
@ 2025-03-10 13:26 ` Arnd Bergmann
  2025-03-10 17:27   ` Eric Biggers
  2025-03-10 17:24 ` [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Eric Biggers
  1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2025-03-10 13:26 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Justin M. Forbes, Jason A. Donenfeld
  Cc: Arnd Bergmann, Ard Biesheuvel, Jarkko Sakkinen, James Bottomley,
	linux-crypto, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Any driver that needs these library functions should already be selecting
the corresponding Kconfig symbols, so there is no real point in making
these visible.

The original patch that made these user selectable described problems
with drivers failing to select the code they use, but as far as I can
tell, those were all bugs that got solved in the meantime and did not
get solved by that patch.

Fixes: e56e18985596 ("lib/crypto: add prompts back to crypto libraries")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
----
This does not actually fix a build failure, but I noticed that the
user visible options don't really make sense. Feel free to ignore
this one.
---
 lib/crypto/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index 17322f871586..798972b29b68 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -63,7 +63,7 @@ config CRYPTO_LIB_CHACHA_INTERNAL
 	select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n
 
 config CRYPTO_LIB_CHACHA
-	tristate "ChaCha library interface"
+	tristate
 	select CRYPTO
 	select CRYPTO_LIB_CHACHA_INTERNAL
 	help
@@ -93,7 +93,7 @@ config CRYPTO_LIB_CURVE25519_INTERNAL
 	select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
 
 config CRYPTO_LIB_CURVE25519
-	tristate "Curve25519 scalar multiplication library"
+	tristate
 	select CRYPTO
 	select CRYPTO_LIB_CURVE25519_INTERNAL
 	help
@@ -132,7 +132,7 @@ config CRYPTO_LIB_POLY1305_INTERNAL
 	select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n
 
 config CRYPTO_LIB_POLY1305
-	tristate "Poly1305 library interface"
+	tristate
 	select CRYPTO
 	select CRYPTO_LIB_POLY1305_INTERNAL
 	help
@@ -141,7 +141,7 @@ config CRYPTO_LIB_POLY1305
 	  is available and enabled.
 
 config CRYPTO_LIB_CHACHA20POLY1305
-	tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)"
+	tristate
 	select CRYPTO_LIB_CHACHA
 	select CRYPTO_LIB_POLY1305
 	select CRYPTO_LIB_UTILS
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: fix dependencies on lib/crypto modules
  2025-03-10 13:26 [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Arnd Bergmann
  2025-03-10 13:26 ` [PATCH 2/2] crypto: lib/Kconfig: hide library options Arnd Bergmann
@ 2025-03-10 17:24 ` Eric Biggers
  2025-03-11 12:32   ` Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Biggers @ 2025-03-10 17:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Herbert Xu, David S. Miller, Arnd Bergmann, Ard Biesheuvel,
	Lukas Wunner, Stephan Mueller, linux-crypto, linux-kernel

On Mon, Mar 10, 2025 at 02:26:39PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The crypto subsystem helpers for chacha, poly1305 and curve25519 were
> changed to select the 'INTERNAL' Kconfig symbols, but the code references
> the generic implementation instead, which leads to a link failure when
> nothing else selects it.
> 
> ld.lld-21: error: undefined symbol: chacha_crypt_generic
> >>> referenced by chacha_generic.c
> >>>               crypto/chacha_generic.o:(chacha_stream_xor) in archive vmlinux.a
> 
> ld.lld-21: error: undefined symbol: poly1305_final_generic
> >>> referenced by poly1305_generic.c
> >>>               crypto/poly1305_generic.o:(crypto_poly1305_final) in archive vmlinux.a
> 
> The INTERNAL version turns on the architecture specific optimized cipher,
> which normally usually also enables the generic version, but this is not
> the case on all architectures. Selecting only the GENERIC version here is
> not sufficient since the architecture specific ones are now hidden symbols
> and are only built when the INTERNAL symbol is also available.
> 
> Fixes: 17ec3e71ba79 ("crypto: lib/Kconfig - Hide arch options from user")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  crypto/Kconfig | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/crypto/Kconfig b/crypto/Kconfig
> index aac27a4668fd..76693e3edff8 100644
> --- a/crypto/Kconfig
> +++ b/crypto/Kconfig
> @@ -317,6 +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,6 +616,7 @@ config CRYPTO_ARC4
>  
>  config CRYPTO_CHACHA20
>  	tristate "ChaCha"
> +	select CRYPTO_LIB_CHACHA_GENERIC
>  	select CRYPTO_LIB_CHACHA_INTERNAL
>  	select CRYPTO_SKCIPHER
>  	help
> @@ -936,6 +938,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)

Looks the same as
https://lore.kernel.org/linux-crypto/Z8UdUoaKtDKzgPph@gondor.apana.org.au/ which
was already applied.

- Eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] crypto: lib/Kconfig: hide library options
  2025-03-10 13:26 ` [PATCH 2/2] crypto: lib/Kconfig: hide library options Arnd Bergmann
@ 2025-03-10 17:27   ` Eric Biggers
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Biggers @ 2025-03-10 17:27 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Herbert Xu, David S. Miller, Justin M. Forbes, Jason A. Donenfeld,
	Arnd Bergmann, Ard Biesheuvel, Jarkko Sakkinen, James Bottomley,
	linux-crypto, linux-kernel

On Mon, Mar 10, 2025 at 02:26:40PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Any driver that needs these library functions should already be selecting
> the corresponding Kconfig symbols, so there is no real point in making
> these visible.
> 
> The original patch that made these user selectable described problems
> with drivers failing to select the code they use, but as far as I can
> tell, those were all bugs that got solved in the meantime and did not
> get solved by that patch.
> 
> Fixes: e56e18985596 ("lib/crypto: add prompts back to crypto libraries")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ----
> This does not actually fix a build failure, but I noticed that the
> user visible options don't really make sense. Feel free to ignore
> this one.

Acked-by: Eric Biggers <ebiggers@kernel.org>

But I think the following needs to be fixed first:

    config BIG_KEYS
            bool "Large payload keys"
            depends on KEYS
            depends on TMPFS
            depends on CRYPTO_LIB_CHACHA20POLY1305 = y

- Eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: fix dependencies on lib/crypto modules
  2025-03-10 17:24 ` [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Eric Biggers
@ 2025-03-11 12:32   ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-03-11 12:32 UTC (permalink / raw)
  To: Eric Biggers, Arnd Bergmann
  Cc: Herbert Xu, David S . Miller, Ard Biesheuvel, Lukas Wunner,
	Stephan Mueller, linux-crypto, linux-kernel

On Mon, Mar 10, 2025, at 18:24, Eric Biggers wrote:
> On Mon, Mar 10, 2025 at 02:26:39PM +0100, Arnd Bergmann wrote:
>
> Looks the same as
> https://lore.kernel.org/linux-crypto/Z8UdUoaKtDKzgPph@gondor.apana.org.au/ which
> was already applied.
>

Right, I see it in today's linux-next. I should have waited a day...

     Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-11 12:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 13:26 [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Arnd Bergmann
2025-03-10 13:26 ` [PATCH 2/2] crypto: lib/Kconfig: hide library options Arnd Bergmann
2025-03-10 17:27   ` Eric Biggers
2025-03-10 17:24 ` [PATCH 1/2] crypto: fix dependencies on lib/crypto modules Eric Biggers
2025-03-11 12:32   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox