diff mbox series

Bluetooth: HCI: Fix authentication failure error during pairing

Message ID 20211130095643.3140-1-sathish.narasimman@intel.com (mailing list archive)
State Changes Requested
Headers show
Series Bluetooth: HCI: Fix authentication failure error during pairing | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 493, Passed: 492 (99.8%), Failed: 0, Not Run: 1
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Sathish Narasimman Nov. 30, 2021, 9:56 a.m. UTC
When Experimental LL_Privacy enabled & Privacy is set to device mode the
pairing of 2 linux devices fails with authentication failure error. This
happens only on the 2nd attempt when we swap the advertiser/initiator
role. This is because the init_addr is updated with dev->rpa which still
holds the previous connection RPA. This patch fixes the issue when
ll_privacy is enabled.

Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
---
 net/bluetooth/hci_event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Luiz Augusto von Dentz Nov. 30, 2021, 7:21 p.m. UTC | #1
Hi Sathish,

On Tue, Nov 30, 2021 at 7:23 AM Sathish Narasimman
<sathish.narasimman@intel.com> wrote:
>
> When Experimental LL_Privacy enabled & Privacy is set to device mode the
> pairing of 2 linux devices fails with authentication failure error. This
> happens only on the 2nd attempt when we swap the advertiser/initiator
> role. This is because the init_addr is updated with dev->rpa which still
> holds the previous connection RPA. This patch fixes the issue when
> ll_privacy is enabled.

What does the previous RPA has to do with the 2nd connection? This
doesn't explain exactly what is the problem, does this means that
local_rpa is not used on the 2nd connection? And why would the
controller not set a local_rpa?

> Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
> ---
>  net/bluetooth/hci_event.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 9d8d2d9e5d1f..bd40d8cedc27 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -5314,8 +5314,10 @@ static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr,
>                         conn->init_addr_type = ADDR_LE_DEV_RANDOM;
>                         bacpy(&conn->init_addr, local_rpa);
>                 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) {
> -                       conn->init_addr_type = ADDR_LE_DEV_RANDOM;
> -                       bacpy(&conn->init_addr, &conn->hdev->rpa);
> +                       if (!use_ll_privacy(conn->hdev)) {
> +                               conn->init_addr_type = ADDR_LE_DEV_RANDOM;
> +                               bacpy(&conn->init_addr, &conn->hdev->rpa);
> +                       }

This can't be right, first it doesn't set any init address and second
I would expect the controller to always set a local_rpa when LL
Privacy is enabled. I suspect the controller is either getting
confused with the first pairing and then the swapping of the roles
with the removal of the devices or there is some else at play because
neither local_rpa or hdev->rpa seems to be set in the init_addr.

>                 } else {
>                         hci_copy_identity_address(conn->hdev, &conn->init_addr,
>                                                   &conn->init_addr_type);
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9d8d2d9e5d1f..bd40d8cedc27 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -5314,8 +5314,10 @@  static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr,
 			conn->init_addr_type = ADDR_LE_DEV_RANDOM;
 			bacpy(&conn->init_addr, local_rpa);
 		} else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) {
-			conn->init_addr_type = ADDR_LE_DEV_RANDOM;
-			bacpy(&conn->init_addr, &conn->hdev->rpa);
+			if (!use_ll_privacy(conn->hdev)) {
+				conn->init_addr_type = ADDR_LE_DEV_RANDOM;
+				bacpy(&conn->init_addr, &conn->hdev->rpa);
+			}
 		} else {
 			hci_copy_identity_address(conn->hdev, &conn->init_addr,
 						  &conn->init_addr_type);