From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Wed, 10 Mar 2021 14:13:08 -0800
Subject: [PATCH] Bluetooth: SMP: Fail if remote and local public keys are
identical
Patch-mainline: v5.13-rc1
Git-commit: 6d19628f539fccf899298ff02ee4c73e4bf6df3f
References: bsc#1186463 CVE-2021-0129 CVE-2020-26558
This fails the pairing procedure when both remote and local non-debug
public keys are identical.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Cho, Yu-Chen <acho@suse.com>
---
net/bluetooth/smp.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2693,6 +2693,15 @@ static int smp_cmd_public_key(struct l2c
if (skb->len < sizeof(*key))
return SMP_INVALID_PARAMS;
+ /* Check if remote and local public keys are the same and debug key is
+ * not in use.
+ */
+ if (!test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags) &&
+ !crypto_memneq(key, smp->local_pk, 64)) {
+ bt_dev_err(hdev, "Remote and local public keys are identical");
+ return SMP_UNSPECIFIED;
+ }
+
memcpy(smp->remote_pk, key, 64);
if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) {