summaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-03-10 14:13:08 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-26 12:05:21 +0200
commitf97257cde764ad6979a7dbeb460b9fb69276342e (patch)
tree71023674c5f1adea800187cf00fd9d23781b7fa3 /net/bluetooth
parent46b4a9c68572f2c864dd204dbda6da34458c8b1a (diff)
downloadlinux-stable-f97257cde764ad6979a7dbeb460b9fb69276342e.tar.gz
linux-stable-f97257cde764ad6979a7dbeb460b9fb69276342e.tar.bz2
linux-stable-f97257cde764ad6979a7dbeb460b9fb69276342e.zip
Bluetooth: SMP: Fail if remote and local public keys are identical
commit 6d19628f539fccf899298ff02ee4c73e4bf6df3f upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/smp.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 26e8cfad22b8..4d5ba9778885 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2685,6 +2685,15 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
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)) {