Skip to content

Commit e5e3f36

Browse files
committed
Merge tag 'for-net-2024-09-27' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - btmrvl: Use IRQF_NO_AUTOEN flag in request_irq() - MGMT: Fix possible crash on mgmt_index_removed - L2CAP: Fix uaf in l2cap_connect - Bluetooth: hci_event: Align BR/EDR JUST_WORKS paring with LE * tag 'for-net-2024-09-27' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: hci_event: Align BR/EDR JUST_WORKS paring with LE Bluetooth: btmrvl: Use IRQF_NO_AUTOEN flag in request_irq() Bluetooth: L2CAP: Fix uaf in l2cap_connect Bluetooth: MGMT: Fix possible crash on mgmt_index_removed ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents cb3ad11 + b25e11f commit e5e3f36

File tree

5 files changed

+23
-28
lines changed

5 files changed

+23
-28
lines changed

drivers/bluetooth/btmrvl_sdio.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int btmrvl_sdio_probe_of(struct device *dev,
9292
} else {
9393
ret = devm_request_irq(dev, cfg->irq_bt,
9494
btmrvl_wake_irq_bt,
95-
0, "bt_wake", card);
95+
IRQF_NO_AUTOEN, "bt_wake", card);
9696
if (ret) {
9797
dev_err(dev,
9898
"Failed to request irq_bt %d (%d)\n",
@@ -101,7 +101,6 @@ static int btmrvl_sdio_probe_of(struct device *dev,
101101

102102
/* Configure wakeup (enabled by default) */
103103
device_init_wakeup(dev, true);
104-
disable_irq(cfg->irq_bt);
105104
}
106105
}
107106

net/bluetooth/hci_core.c

+2
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,8 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
37823782

37833783
hci_dev_lock(hdev);
37843784
conn = hci_conn_hash_lookup_handle(hdev, handle);
3785+
if (conn && hci_dev_test_flag(hdev, HCI_MGMT))
3786+
mgmt_device_connected(hdev, conn, NULL, 0);
37853787
hci_dev_unlock(hdev);
37863788

37873789
if (conn) {

net/bluetooth/hci_event.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,7 @@ static void hci_remote_features_evt(struct hci_dev *hdev, void *data,
37063706
goto unlock;
37073707
}
37083708

3709-
if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) {
3709+
if (!ev->status) {
37103710
struct hci_cp_remote_name_req cp;
37113711
memset(&cp, 0, sizeof(cp));
37123712
bacpy(&cp.bdaddr, &conn->dst);
@@ -5324,19 +5324,16 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev, void *data,
53245324
goto unlock;
53255325
}
53265326

5327-
/* If no side requires MITM protection; auto-accept */
5327+
/* If no side requires MITM protection; use JUST_CFM method */
53285328
if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) &&
53295329
(!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) {
53305330

5331-
/* If we're not the initiators request authorization to
5332-
* proceed from user space (mgmt_user_confirm with
5333-
* confirm_hint set to 1). The exception is if neither
5334-
* side had MITM or if the local IO capability is
5335-
* NoInputNoOutput, in which case we do auto-accept
5331+
/* If we're not the initiator of request authorization and the
5332+
* local IO capability is not NoInputNoOutput, use JUST_WORKS
5333+
* method (mgmt_user_confirm with confirm_hint set to 1).
53365334
*/
53375335
if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) &&
5338-
conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
5339-
(loc_mitm || rem_mitm)) {
5336+
conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) {
53405337
bt_dev_dbg(hdev, "Confirming auto-accept as acceptor");
53415338
confirm_hint = 1;
53425339
goto confirm;

net/bluetooth/l2cap_core.c

-8
Original file line numberDiff line numberDiff line change
@@ -4066,17 +4066,9 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
40664066
static int l2cap_connect_req(struct l2cap_conn *conn,
40674067
struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
40684068
{
4069-
struct hci_dev *hdev = conn->hcon->hdev;
4070-
struct hci_conn *hcon = conn->hcon;
4071-
40724069
if (cmd_len < sizeof(struct l2cap_conn_req))
40734070
return -EPROTO;
40744071

4075-
hci_dev_lock(hdev);
4076-
if (hci_dev_test_flag(hdev, HCI_MGMT))
4077-
mgmt_device_connected(hdev, hcon, NULL, 0);
4078-
hci_dev_unlock(hdev);
4079-
40804072
l2cap_connect(conn, cmd, data, L2CAP_CONN_RSP);
40814073
return 0;
40824074
}

net/bluetooth/mgmt.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -1453,10 +1453,15 @@ static void cmd_status_rsp(struct mgmt_pending_cmd *cmd, void *data)
14531453

14541454
static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)
14551455
{
1456-
if (cmd->cmd_complete) {
1457-
u8 *status = data;
1456+
struct cmd_lookup *match = data;
1457+
1458+
/* dequeue cmd_sync entries using cmd as data as that is about to be
1459+
* removed/freed.
1460+
*/
1461+
hci_cmd_sync_dequeue(match->hdev, NULL, cmd, NULL);
14581462

1459-
cmd->cmd_complete(cmd, *status);
1463+
if (cmd->cmd_complete) {
1464+
cmd->cmd_complete(cmd, match->mgmt_status);
14601465
mgmt_pending_remove(cmd);
14611466

14621467
return;
@@ -9394,12 +9399,12 @@ void mgmt_index_added(struct hci_dev *hdev)
93949399
void mgmt_index_removed(struct hci_dev *hdev)
93959400
{
93969401
struct mgmt_ev_ext_index ev;
9397-
u8 status = MGMT_STATUS_INVALID_INDEX;
9402+
struct cmd_lookup match = { NULL, hdev, MGMT_STATUS_INVALID_INDEX };
93989403

93999404
if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
94009405
return;
94019406

9402-
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status);
9407+
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &match);
94039408

94049409
if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
94059410
mgmt_index_event(MGMT_EV_UNCONF_INDEX_REMOVED, hdev, NULL, 0,
@@ -9450,7 +9455,7 @@ void mgmt_power_on(struct hci_dev *hdev, int err)
94509455
void __mgmt_power_off(struct hci_dev *hdev)
94519456
{
94529457
struct cmd_lookup match = { NULL, hdev };
9453-
u8 status, zero_cod[] = { 0, 0, 0 };
9458+
u8 zero_cod[] = { 0, 0, 0 };
94549459

94559460
mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);
94569461

@@ -9462,11 +9467,11 @@ void __mgmt_power_off(struct hci_dev *hdev)
94629467
* status responses.
94639468
*/
94649469
if (hci_dev_test_flag(hdev, HCI_UNREGISTER))
9465-
status = MGMT_STATUS_INVALID_INDEX;
9470+
match.mgmt_status = MGMT_STATUS_INVALID_INDEX;
94669471
else
9467-
status = MGMT_STATUS_NOT_POWERED;
9472+
match.mgmt_status = MGMT_STATUS_NOT_POWERED;
94689473

9469-
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status);
9474+
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &match);
94709475

94719476
if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) {
94729477
mgmt_limited_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,

0 commit comments

Comments
 (0)