]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: SMP: Fail if remote and local public keys are identical
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 10 Mar 2021 22:13:08 +0000 (14:13 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 May 2021 10:05:21 +0000 (12:05 +0200)
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>
net/bluetooth/smp.c

index 26e8cfad22b8ed9e209e5edfe4b7fd773785b715..4d5ba9778885d9aabebc2351afe3704d4791cd4f 100644 (file)
@@ -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)) {