blob: 1d8a5dbd85d32a90dfda1814873331c32212da03 [file] [log] [blame]
From 5cff5c09f0db99734ac3ea0d1af161b33ca91043 Mon Sep 17 00:00:00 2001
From: Zhengping Jiang <jiangzp@google.com>
Date: Mon, 5 Jun 2023 09:28:28 -0700
Subject: [PATCH] Revert "Bluetooth: MGMT: Fix Get Device Flags"
This reverts commit 529d4492aed7c005206383b84c38d515c31c1585.
Original commit message:
Bluetooth: MGMT: Fix Get Device Flags
Get Device Flags don't check if device does actually use an RPA in which
case it shall only set HCI_CONN_FLAG_REMOTE_WAKEUP if LL Privacy is
enabled.
Reason: this patch causes HID devices with IRK but not using RPA
fail to wakeup devices.
BUG=b:281452358
TEST=build
Change-Id: Iada8a5dda630e5f73f37523677651f2a74c97f6e
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4521884
Tested-by: Yun-Hao Chung <howardchung@chromium.org>
Commit-Queue: Yun-Hao Chung <howardchung@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Reviewed-by: Manish Mandlik <mmandlik@chromium.org>
---
net/bluetooth/mgmt.c | 68 ++++++++++++++++++--------------------------
1 file changed, 27 insertions(+), 41 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a3eaa70883b9d29de169b61374aaded15150c63e..79041796f882b16b5032cec2b78d795c93d59709 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5039,22 +5039,6 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev,
MGMT_STATUS_NOT_SUPPORTED);
}
-static u32 get_params_flags(struct hci_dev *hdev,
- struct hci_conn_params *params)
-{
- u32 flags = hdev->conn_flags;
-
- /* Devices using RPAs can only be programmed in the acceptlist if
- * LL Privacy has been enable otherwise they cannot mark
- * HCI_CONN_FLAG_REMOTE_WAKEUP.
- */
- if ((flags & HCI_CONN_FLAG_REMOTE_WAKEUP) && !use_ll_privacy(hdev) &&
- hci_find_irk_by_addr(hdev, &params->addr, params->addr_type))
- flags &= ~HCI_CONN_FLAG_REMOTE_WAKEUP;
-
- return flags;
-}
-
int mgmt_quality_report(struct hci_dev *hdev, struct sk_buff *skb,
u8 quality_spec)
{
@@ -5111,7 +5095,6 @@ static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
if (!params)
goto done;
- supported_flags = get_params_flags(hdev, params);
current_flags = params->flags;
}
@@ -5179,34 +5162,37 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
bt_dev_warn(hdev, "No such BR/EDR device %pMR (0x%x)",
&cp->addr.bdaddr, cp->addr.type);
}
-
- goto unlock;
- }
-
- params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
- le_addr_type(cp->addr.type));
- if (!params) {
- bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
- &cp->addr.bdaddr, le_addr_type(cp->addr.type));
- goto unlock;
- }
-
- supported_flags = get_params_flags(hdev, params);
-
- if ((supported_flags | current_flags) != supported_flags) {
- bt_dev_warn(hdev, "Bad flag given (0x%x) vs supported (0x%0x)",
- current_flags, supported_flags);
- goto unlock;
- }
+ } else {
+ params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
+ le_addr_type(cp->addr.type));
+ if (params) {
+ /* Devices using RPAs can only be programmed in the
+ * acceptlist LL Privacy has been enable otherwise they
+ * cannot mark HCI_CONN_FLAG_REMOTE_WAKEUP.
+ */
+ if ((current_flags & HCI_CONN_FLAG_REMOTE_WAKEUP) &&
+ !use_ll_privacy(hdev) &&
+ hci_find_irk_by_addr(hdev, &params->addr,
+ params->addr_type)) {
+ bt_dev_warn(hdev,
+ "Cannot set wakeable for RPA");
+ goto unlock;
+ }
WRITE_ONCE(params->flags, current_flags);
status = MGMT_STATUS_SUCCESS;
- /* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY
- * has been set.
- */
- if (params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY)
- hci_update_passive_scan(hdev);
+ /* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY
+ * has been set.
+ */
+ if (params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY)
+ hci_update_passive_scan(hdev);
+ } else {
+ bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
+ &cp->addr.bdaddr,
+ le_addr_type(cp->addr.type));
+ }
+ }
unlock:
hci_dev_unlock(hdev);
--
2.34.1