fixup! Bluetooth: MGMT: Fix possible UAFs
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 fixup! Bluetooth: MGMT: Fix possible UAFs
From: Luiz Augusto von Dentz <[email protected]>
Signed-off-by Luiz Augusto von Dentz <[email protected]>
--- net/bluetooth/mgmt.c | 29 ++++++++++++++++++++++++++++- net/bluetooth/mgmt_util.c | 7 ++++--- net/bluetooth/mgmt_util.h | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-)
net/bluetooth/mgmt.c +28 -1
@@ -1357,6 +1357,7 @@ static int set_powered_sync(struct hci_dev *hdev, void *data) {struct mgmt_pending_cmd *cmd = data;struct mgmt_mode *cp; +int err;/* Make sure cmd still outstanding. */ if (!mgmt_pending_valid (hdev, cmd, false))
@@ -1366,7 +1367,11 @@ static int set_powered_sync(struct hci_dev *hdev, void *data)BT_DBG ("%s" , hdev->name); -return hci_set_powered_sync (hdev, cp->val); + err =hci_set_powered_sync (hdev, cp->val); + +mutex_unlock (&hdev->mgmt_pending_lock); + +return err; } static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
@@ -1546,6 +1551,8 @@ static int set_discoverable_sync(struct hci_dev *hdev, void *data)if (!mgmt_pending_valid (hdev, data, false))return -ECANCELED ; +mutex_unlock (&hdev->mgmt_pending_lock); +BT_DBG ("%s" , hdev->name);return hci_update_discoverable_sync (hdev);
@@ -1746,6 +1753,8 @@ static int set_connectable_sync(struct hci_dev *hdev, void *data)if (!mgmt_pending_valid (hdev, data, false))return -ECANCELED ; +mutex_unlock (&hdev->mgmt_pending_lock); +BT_DBG ("%s" , hdev->name);return hci_update_connectable_sync (hdev);
@@ -1979,6 +1988,8 @@ static int set_ssp_sync(struct hci_dev *hdev, void *data) err =hci_write_ssp_mode_sync (hdev, cp->val); +mutex_unlock (&hdev->mgmt_pending_lock); +if (!err && changed)hci_dev_clear_flag (hdev,HCI_SSP_ENABLED );
@@ -2108,6 +2119,8 @@ static int set_le_sync(struct hci_dev *hdev, void *data) cp = cmd->param; val = !!cp->val; +mutex_unlock (&hdev->mgmt_pending_lock); +if (!val) {hci_clear_adv_instance_sync (hdev,NULL ,0x00 , true);
@@ -2190,6 +2203,8 @@ static int set_mesh_sync(struct hci_dev *hdev, void *data) len -=sizeof (*cp); +mutex_unlock (&hdev->mgmt_pending_lock); +/* If filters don't fit, forward all adv pkts */ if (len <=sizeof (hdev->mesh_ad_types))memcpy (hdev->mesh_ad_types, cp->ad_types, len);
@@ -3939,6 +3954,8 @@ static int set_name_sync(struct hci_dev *hdev, void *data)hci_update_eir_sync (hdev); } +mutex_unlock (&hdev->mgmt_pending_lock); +/* The name is stored in the scan response data and so * no need to update the advertising data here. */
@@ -4162,6 +4179,8 @@ static int set_default_phy_sync(struct hci_dev *hdev, void *data)if (selected_phys &MGMT_PHY_LE_CODED_RX ) cp_phy.rx_phys |=HCI_LE_SET_PHY_CODED ; +mutex_unlock (&hdev->mgmt_pending_lock); + cmd->skb =__hci_cmd_sync (hdev,HCI_OP_LE_SET_DEFAULT_PHY ,sizeof (cp_phy), &cp_phy,HCI_CMD_TIMEOUT );
@@ -5273,6 +5292,8 @@ static int mgmt_add_adv_patterns_monitor_sync(struct hci_dev *hdev, void *data)if (!mgmt_pending_valid (hdev, cmd, false))return -ECANCELED ; +mutex_unlock (&hdev->mgmt_pending_lock); +return hci_add_adv_monitor (hdev, cmd->user_data); }
@@ -5860,6 +5881,8 @@ static int start_discovery_sync(struct hci_dev *hdev, void *data)if (!mgmt_pending_valid (hdev, data, false))return -ECANCELED ; +mutex_unlock (&hdev->mgmt_pending_lock); +return hci_start_discovery_sync (hdev); }
@@ -6083,6 +6106,8 @@ static int stop_discovery_sync(struct hci_dev *hdev, void *data)if (!mgmt_pending_valid (hdev, data, false))return -ECANCELED ; +mutex_unlock (&hdev->mgmt_pending_lock); +return hci_stop_discovery_sync (hdev); }
@@ -6358,6 +6383,8 @@ static int set_adv_sync(struct hci_dev *hdev, void *data)else hci_dev_clear_flag (hdev,HCI_ADVERTISING_CONNECTABLE ); +mutex_unlock (&hdev->mgmt_pending_lock); +cancel_adv_timeout (hdev);if (val) {
net/bluetooth/mgmt_util.c +4 -3
@@ -321,7 +321,7 @@ void mgmt_pending_remove(struct mgmt_pending_cmd *cmd) }bool mgmt_pending_valid (struct hci_dev *hdev,struct mgmt_pending_cmd *cmd, -bool remove) +bool remove_unlock) {struct mgmt_pending_cmd *tmp;
@@ -332,9 +332,10 @@ bool mgmt_pending_valid(struct hci_dev *hdev, struct mgmt_pending_cmd *cmd,list_for_each_entry (tmp, &hdev->mgmt_pending, list) {if (cmd == tmp) { -if (remove) +if (remove_unlock) {list_del (&cmd->list); -mutex_unlock (&hdev->mgmt_pending_lock); +mutex_unlock (&hdev->mgmt_pending_lock); + }return true; } }
net/bluetooth/mgmt_util.h +1 -1
@@ -66,7 +66,7 @@ struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode,void mgmt_pending_free (struct mgmt_pending_cmd *cmd);void mgmt_pending_remove (struct mgmt_pending_cmd *cmd);bool mgmt_pending_valid (struct hci_dev *hdev,struct mgmt_pending_cmd *cmd, -bool remove); +bool remove_unlock);void mgmt_mesh_foreach (struct hci_dev *hdev,void (*cb)(struct mgmt_mesh_tx *mesh_tx,void *data),void *data,struct sock *sk);
Signature · 1 line
2.51.0