Commit f61060fb authored by Jakub Kicinski's avatar Jakub Kicinski

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/20241004210124.4010321-1-luiz.dentz@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 83211ae1 61071229
...@@ -4038,16 +4038,29 @@ static void btusb_disconnect(struct usb_interface *intf) ...@@ -4038,16 +4038,29 @@ static void btusb_disconnect(struct usb_interface *intf)
static int btusb_suspend(struct usb_interface *intf, pm_message_t message) static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
{ {
struct btusb_data *data = usb_get_intfdata(intf); struct btusb_data *data = usb_get_intfdata(intf);
int err;
BT_DBG("intf %p", intf); BT_DBG("intf %p", intf);
/* Don't suspend if there are connections */ /* Don't auto-suspend if there are connections; external suspend calls
if (hci_conn_count(data->hdev)) * shall never fail.
*/
if (PMSG_IS_AUTO(message) && hci_conn_count(data->hdev))
return -EBUSY; return -EBUSY;
if (data->suspend_count++) if (data->suspend_count++)
return 0; return 0;
/* Notify Host stack to suspend; this has to be done before stopping
* the traffic since the hci_suspend_dev itself may generate some
* traffic.
*/
err = hci_suspend_dev(data->hdev);
if (err) {
data->suspend_count--;
return err;
}
spin_lock_irq(&data->txlock); spin_lock_irq(&data->txlock);
if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) { if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
set_bit(BTUSB_SUSPENDING, &data->flags); set_bit(BTUSB_SUSPENDING, &data->flags);
...@@ -4055,6 +4068,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -4055,6 +4068,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
} else { } else {
spin_unlock_irq(&data->txlock); spin_unlock_irq(&data->txlock);
data->suspend_count--; data->suspend_count--;
hci_resume_dev(data->hdev);
return -EBUSY; return -EBUSY;
} }
...@@ -4175,6 +4189,8 @@ static int btusb_resume(struct usb_interface *intf) ...@@ -4175,6 +4189,8 @@ static int btusb_resume(struct usb_interface *intf)
spin_unlock_irq(&data->txlock); spin_unlock_irq(&data->txlock);
schedule_work(&data->work); schedule_work(&data->work);
hci_resume_dev(data->hdev);
return 0; return 0;
failed: failed:
......
...@@ -289,6 +289,9 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data) ...@@ -289,6 +289,9 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
kfree(conn_handle); kfree(conn_handle);
if (!hci_conn_valid(hdev, conn))
return -ECANCELED;
bt_dev_dbg(hdev, "hcon %p", conn); bt_dev_dbg(hdev, "hcon %p", conn);
configure_datapath_sync(hdev, &conn->codec); configure_datapath_sync(hdev, &conn->codec);
......
...@@ -865,9 +865,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon ...@@ -865,9 +865,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon
if (err == -ENOIOCTLCMD) { if (err == -ENOIOCTLCMD) {
#ifdef CONFIG_BT_RFCOMM_TTY #ifdef CONFIG_BT_RFCOMM_TTY
lock_sock(sk);
err = rfcomm_dev_ioctl(sk, cmd, (void __user *) arg); err = rfcomm_dev_ioctl(sk, cmd, (void __user *) arg);
release_sock(sk);
#else #else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment