Internal Error from Kernel When Connecting a Bluetooth Device

Looks like Nvidia somehow managed to mangle the NIST P256 curve? Here’s the correct one:

--- kernel/kernel-5.10/crypto/ecc.c	2023-07-29 21:04:43.469231617 -0400
+++ kernel/kernel-5.10/crypto/ecc.c	2023-07-29 21:07:47.188380995 -0400
@@ -70,6 +70,10 @@ static u64 nist_p256_p[] = { 0xFFFFFFFFF
 				0x0000000000000000ull, 0xFFFFFFFF00000001ull };
 static u64 nist_p256_n[] = { 0xF3B9CAC2FC632551ull, 0xBCE6FAADA7179E84ull,
 				0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFF00000000ull };
+static u64 nist_p256_a[] = { 0xFFFFFFFFFFFFFFFCull, 0x00000000FFFFFFFFull,
+				0x0000000000000000ull, 0xFFFFFFFF00000001ull };
+static u64 nist_p256_b[] = { 0x3BCE3C3E27D2604Bull, 0x651D06B0CC53B0F6ull,
+				0xB3EBBD55769886BCull, 0x5AC635D8AA3A93E7ull };
 static struct ecc_curve nist_p256 = {
 	.name = "nist_256",
 	.g = {
@@ -78,7 +82,9 @@ static struct ecc_curve nist_p256 = {
 		.ndigits = 4,
 	},
 	.p = nist_p256_p,
-	.n = nist_p256_n
+	.n = nist_p256_n,
+	.a = nist_p256_a,
+	.b = nist_p256_b
 };
 
 /* BrainPool P-256 */

Note that this is exactly the same as the one here: ecc_curve_defs.h - crypto/ecc_curve_defs.h - Linux source code (v5.10.148) - Bootlin

To fix, update crypto/ecc.c with this patch, rebuild the kernel, and copy the Image to /boot.

Tested on both XBox and Stadia bluetooth controllers.

@doruk.sonmez1 @eugenyshcheglov , can you confirm this fixes the issues for you?

Edit: Also tested my logitech mouse that was failing earlier, and it works great now.

2 Likes