Skip to content

Commit f61060f

Browse files
committed
Merge tag 'for-net-2024-10-04' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - RFCOMM: FIX possible deadlock in rfcomm_sk_state_change - hci_conn: Fix UAF in hci_enhanced_setup_sync - btusb: Don't fail external suspend requests * tag 'for-net-2024-10-04' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: btusb: Don't fail external suspend requests Bluetooth: hci_conn: Fix UAF in hci_enhanced_setup_sync Bluetooth: RFCOMM: FIX possible deadlock in rfcomm_sk_state_change ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 83211ae + 6107122 commit f61060f

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

drivers/bluetooth/btusb.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,23 +4038,37 @@ static void btusb_disconnect(struct usb_interface *intf)
40384038
static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
40394039
{
40404040
struct btusb_data *data = usb_get_intfdata(intf);
4041+
int err;
40414042

40424043
BT_DBG("intf %p", intf);
40434044

4044-
/* Don't suspend if there are connections */
4045-
if (hci_conn_count(data->hdev))
4045+
/* Don't auto-suspend if there are connections; external suspend calls
4046+
* shall never fail.
4047+
*/
4048+
if (PMSG_IS_AUTO(message) && hci_conn_count(data->hdev))
40464049
return -EBUSY;
40474050

40484051
if (data->suspend_count++)
40494052
return 0;
40504053

4054+
/* Notify Host stack to suspend; this has to be done before stopping
4055+
* the traffic since the hci_suspend_dev itself may generate some
4056+
* traffic.
4057+
*/
4058+
err = hci_suspend_dev(data->hdev);
4059+
if (err) {
4060+
data->suspend_count--;
4061+
return err;
4062+
}
4063+
40514064
spin_lock_irq(&data->txlock);
40524065
if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
40534066
set_bit(BTUSB_SUSPENDING, &data->flags);
40544067
spin_unlock_irq(&data->txlock);
40554068
} else {
40564069
spin_unlock_irq(&data->txlock);
40574070
data->suspend_count--;
4071+
hci_resume_dev(data->hdev);
40584072
return -EBUSY;
40594073
}
40604074

@@ -4175,6 +4189,8 @@ static int btusb_resume(struct usb_interface *intf)
41754189
spin_unlock_irq(&data->txlock);
41764190
schedule_work(&data->work);
41774191

4192+
hci_resume_dev(data->hdev);
4193+
41784194
return 0;
41794195

41804196
failed:

net/bluetooth/hci_conn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
289289

290290
kfree(conn_handle);
291291

292+
if (!hci_conn_valid(hdev, conn))
293+
return -ECANCELED;
294+
292295
bt_dev_dbg(hdev, "hcon %p", conn);
293296

294297
configure_datapath_sync(hdev, &conn->codec);

net/bluetooth/rfcomm/sock.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon
865865

866866
if (err == -ENOIOCTLCMD) {
867867
#ifdef CONFIG_BT_RFCOMM_TTY
868-
lock_sock(sk);
869868
err = rfcomm_dev_ioctl(sk, cmd, (void __user *) arg);
870-
release_sock(sk);
871869
#else
872870
err = -EOPNOTSUPP;
873871
#endif

0 commit comments

Comments
 (0)