diff mbox series

[crypto] crypto: memneq - move into lib/

Message ID 20220528102429.189731-1-Jason@zx2c4.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [crypto] crypto: memneq - move into lib/ | expand

Commit Message

Jason A. Donenfeld May 28, 2022, 10:24 a.m. UTC
This is used by code that doesn't need CONFIG_CRYPTO, so move this into
lib/ with a Kconfig option so that it can be selected by whatever needs
it.

This fixes a linker error Zheng pointed out when
CRYPTO_MANAGER_DISABLE_TESTS!=y and CRYPTO=m:

  lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
  curve25519-selftest.c:(.init.text+0x60): undefined reference to `__crypto_memneq'
  curve25519-selftest.c:(.init.text+0xec): undefined reference to `__crypto_memneq'
  curve25519-selftest.c:(.init.text+0x114): undefined reference to `__crypto_memneq'
  curve25519-selftest.c:(.init.text+0x154): undefined reference to `__crypto_memneq'

Reported-by: Zheng Bin <zhengbin13@huawei.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: stable@vger.kernel.org
Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
I'm traveling over the next week, and there are a few ways to skin this
cat, so if somebody here sees issue, feel free to pick this v1 up and
fashion a v2 out of it.

 crypto/Kconfig           | 1 +
 crypto/Makefile          | 2 +-
 lib/Kconfig              | 3 +++
 lib/Makefile             | 1 +
 lib/crypto/Kconfig       | 1 +
 {crypto => lib}/memneq.c | 0
 6 files changed, 7 insertions(+), 1 deletion(-)
 rename {crypto => lib}/memneq.c (100%)

Comments

Eric Biggers May 30, 2022, 5:36 p.m. UTC | #1
On Sat, May 28, 2022 at 12:24:29PM +0200, Jason A. Donenfeld wrote:
> This is used by code that doesn't need CONFIG_CRYPTO, so move this into
> lib/ with a Kconfig option so that it can be selected by whatever needs
> it.
> 
> This fixes a linker error Zheng pointed out when
> CRYPTO_MANAGER_DISABLE_TESTS!=y and CRYPTO=m:
> 
>   lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
>   curve25519-selftest.c:(.init.text+0x60): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0xec): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0x114): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0x154): undefined reference to `__crypto_memneq'
> 
> Reported-by: Zheng Bin <zhengbin13@huawei.com>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: stable@vger.kernel.org
> Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> I'm traveling over the next week, and there are a few ways to skin this
> cat, so if somebody here sees issue, feel free to pick this v1 up and
> fashion a v2 out of it.
> 
>  crypto/Kconfig           | 1 +
>  crypto/Makefile          | 2 +-
>  lib/Kconfig              | 3 +++
>  lib/Makefile             | 1 +
>  lib/crypto/Kconfig       | 1 +
>  {crypto => lib}/memneq.c | 0
>  6 files changed, 7 insertions(+), 1 deletion(-)
>  rename {crypto => lib}/memneq.c (100%)

Reviewed-by: Eric Biggers <ebiggers@google.com>

- Eric
Herbert Xu June 10, 2022, 9:16 a.m. UTC | #2
On Sat, May 28, 2022 at 12:24:29PM +0200, Jason A. Donenfeld wrote:
> This is used by code that doesn't need CONFIG_CRYPTO, so move this into
> lib/ with a Kconfig option so that it can be selected by whatever needs
> it.
> 
> This fixes a linker error Zheng pointed out when
> CRYPTO_MANAGER_DISABLE_TESTS!=y and CRYPTO=m:
> 
>   lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
>   curve25519-selftest.c:(.init.text+0x60): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0xec): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0x114): undefined reference to `__crypto_memneq'
>   curve25519-selftest.c:(.init.text+0x154): undefined reference to `__crypto_memneq'
> 
> Reported-by: Zheng Bin <zhengbin13@huawei.com>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: stable@vger.kernel.org
> Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> I'm traveling over the next week, and there are a few ways to skin this
> cat, so if somebody here sees issue, feel free to pick this v1 up and
> fashion a v2 out of it.
> 
>  crypto/Kconfig           | 1 +
>  crypto/Makefile          | 2 +-
>  lib/Kconfig              | 3 +++
>  lib/Makefile             | 1 +
>  lib/crypto/Kconfig       | 1 +
>  {crypto => lib}/memneq.c | 0
>  6 files changed, 7 insertions(+), 1 deletion(-)
>  rename {crypto => lib}/memneq.c (100%)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/Kconfig b/crypto/Kconfig
index f567271ed10d..38601a072b99 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -15,6 +15,7 @@  source "crypto/async_tx/Kconfig"
 #
 menuconfig CRYPTO
 	tristate "Cryptographic API"
+	select LIB_MEMNEQ
 	help
 	  This option provides the core Cryptographic API.
 
diff --git a/crypto/Makefile b/crypto/Makefile
index 40d4c2690a49..dbfa53567c92 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -4,7 +4,7 @@ 
 #
 
 obj-$(CONFIG_CRYPTO) += crypto.o
-crypto-y := api.o cipher.o compress.o memneq.o
+crypto-y := api.o cipher.o compress.o
 
 obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
 obj-$(CONFIG_CRYPTO_FIPS) += fips.o
diff --git a/lib/Kconfig b/lib/Kconfig
index 6a843639814f..eaaad4d85bf2 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -120,6 +120,9 @@  config INDIRECT_IOMEM_FALLBACK
 
 source "lib/crypto/Kconfig"
 
+config LIB_MEMNEQ
+	bool
+
 config CRC_CCITT
 	tristate "CRC-CCITT functions"
 	help
diff --git a/lib/Makefile b/lib/Makefile
index 89fcae891361..f01023cda508 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -251,6 +251,7 @@  obj-$(CONFIG_DIMLIB) += dim/
 obj-$(CONFIG_SIGNATURE) += digsig.o
 
 lib-$(CONFIG_CLZ_TAB) += clz_tab.o
+lib-$(CONFIG_LIB_MEMNEQ) += memneq.o
 
 obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
 obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index 7ee13c08c970..337d6852643a 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -71,6 +71,7 @@  config CRYPTO_LIB_CURVE25519
 	tristate "Curve25519 scalar multiplication library"
 	depends on CRYPTO_ARCH_HAVE_LIB_CURVE25519 || !CRYPTO_ARCH_HAVE_LIB_CURVE25519
 	select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
+	select LIB_MEMNEQ
 	help
 	  Enable the Curve25519 library interface. This interface may be
 	  fulfilled by either the generic implementation or an arch-specific
diff --git a/crypto/memneq.c b/lib/memneq.c
similarity index 100%
rename from crypto/memneq.c
rename to lib/memneq.c