Skip to contentSkip to conversation

lib/crypto: arm/curve25519: Disable on CPU_BIG_ENDIAN

PATCH Applied Eric Biggers 2 participants 3 messages Nov 4, 2025

Subsystems (3)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: arm/curve25519: Disable on CPU_BIG_ENDIAN

On big endian arm kernels, the arm optimized Curve25519 code produces incorrect outputs and fails the Curve25519 test. This has been true ever since this code was added.

It seems that hardly anyone (or even no one?) actually uses big endian arm kernels. But as long as they're ostensibly supported, we should disable this code on them so that it's not accidentally used.

Note: for future-proofing, use !CPU_BIG_ENDIAN instead of CPU_LITTLE_ENDIAN. Both of these are arch-specific options that could get removed in the future if big endian support gets dropped.

Fixes d8f1308a025f ("crypto: arm/curve25519 - wire up NEON implementation")

---

This patch is targeting libcrypto-fixes

 lib/crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crypto/Kconfig +1 -1
index 8886055e938f..16859c6226dd 100644
@@ -62,11 +62,11 @@ config CRYPTO_LIB_CURVE25519
 	  of the functions from <crypto/curve25519.h>.
 
 config CRYPTO_LIB_CURVE25519_ARCH
 	bool
 	depends on CRYPTO_LIB_CURVE25519 && !UML && !KMSAN
-	default y if ARM && KERNEL_MODE_NEON
+	default y if ARM && KERNEL_MODE_NEON && !CPU_BIG_ENDIAN
 	default y if PPC64 && CPU_LITTLE_ENDIAN
 	default y if X86_64
 
 config CRYPTO_LIB_CURVE25519_GENERIC
 	bool

base-commit: 1af424b15401d2be789c4dc2279889514e7c5c94

Signature · 1 line
2.51.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Eric Biggers

On big endian arm kernels, the arm optimized Curve25519 code produces incorrect outputs and fails the Curve25519 test. This has been true ever since this code was added.

It seems that hardly anyone (or even no one?) actually uses big endian arm kernels. But as long as they're ostensibly supported, we should disable this code on them so that it's not accidentally used.

Note: for future-proofing, use !CPU_BIG_ENDIAN instead of CPU_LITTLE_ENDIAN. Both of these are arch-specific options that could get removed in the future if big endian support gets dropped.

Fixes d8f1308a025f ("crypto: arm/curve25519 - wire up NEON implementation")
Quoted 7 lines

---

This patch is targeting libcrypto-fixes

 lib/crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 22 lines
lib/crypto/Kconfig +1 -1
index 8886055e938f..16859c6226dd 100644
@@ -62,11 +62,11 @@ config CRYPTO_LIB_CURVE25519
          of the functions from <crypto/curve25519.h>.
 
 config CRYPTO_LIB_CURVE25519_ARCH
        bool
        depends on CRYPTO_LIB_CURVE25519 && !UML && !KMSAN
-       default y if ARM && KERNEL_MODE_NEON
+       default y if ARM && KERNEL_MODE_NEON && !CPU_BIG_ENDIAN
        default y if PPC64 && CPU_LITTLE_ENDIAN
        default y if X86_64
 
 config CRYPTO_LIB_CURVE25519_GENERIC
        bool

base-commit: 1af424b15401d2be789c4dc2279889514e7c5c94 --
2.51.2

author maintainer Applied
#2 lore raw
In reply to Eric Biggers
Quoted 40 lines · Eric Biggers

On big endian arm kernels, the arm optimized Curve25519 code produces incorrect outputs and fails the Curve25519 test. This has been true ever since this code was added.

It seems that hardly anyone (or even no one?) actually uses big endian arm kernels. But as long as they're ostensibly supported, we should disable this code on them so that it's not accidentally used.

Note: for future-proofing, use !CPU_BIG_ENDIAN instead of CPU_LITTLE_ENDIAN. Both of these are arch-specific options that could get removed in the future if big endian support gets dropped.

Fixes d8f1308a025f ("crypto: arm/curve25519 - wire up NEON implementation")

---

This patch is targeting libcrypto-fixes

 lib/crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crypto/Kconfig +1 -1
index 8886055e938f..16859c6226dd 100644
@@ -62,11 +62,11 @@ config CRYPTO_LIB_CURVE25519
 	  of the functions from <crypto/curve25519.h>.
 
 config CRYPTO_LIB_CURVE25519_ARCH
 	bool
 	depends on CRYPTO_LIB_CURVE25519 && !UML && !KMSAN
-	default y if ARM && KERNEL_MODE_NEON
+	default y if ARM && KERNEL_MODE_NEON && !CPU_BIG_ENDIAN
 	default y if PPC64 && CPU_LITTLE_ENDIAN
 	default y if X86_64
 
 config CRYPTO_LIB_CURVE25519_GENERIC
 	bool
Quoted 4 lines

base-commit: 1af424b15401d2be789c4dc2279889514e7c5c94

Signature · 1 line
2.51.2

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-fixes

- Eric