1. 22 7月, 2017 1 次提交
  2. 18 5月, 2017 1 次提交
    • D
      Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races · dec2c928
      Dean Jenkins 提交于
      When HCI_UART_PROTO_READY is in the set state, the Data Link protocol
      layer (proto) is bound to the HCI UART driver. This state allows the
      registered proto function pointers to be used by the HCI UART driver.
      
      When unbinding (closing) the Data Link protocol layer, the proto
      function pointers much be prevented from being used immediately before
      running the proto close function pointer. Otherwise, there is a risk
      that a proto non-close function pointer is used during or after the
      proto close function pointer is used. The consequences are likely to
      be a kernel crash because the proto close function pointer will free
      resources used in the Data Link protocol layer.
      
      Therefore, add a reader writer lock (rwlock) solution to prevent the
      close proto function pointer from running by using write_lock_irqsave()
      whilst the other proto function pointers are protected using
      read_lock(). This means HCI_UART_PROTO_READY can safely be cleared
      in the knowledge that no proto function pointers are running.
      
      When flag HCI_UART_PROTO_READY is put into the clear state,
      proto close function pointer can safely be run. Note
      flag HCI_UART_PROTO_SET being in the set state prevents the proto
      open function pointer from being run so there is no race condition
      between proto open and close function pointers.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      dec2c928
  3. 30 4月, 2017 3 次提交
    • D
      Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup() · 2d6f1da1
      Dean Jenkins 提交于
      Before attempting to schedule a work-item onto hu->write_work in
      hci_uart_tx_wakeup(), check that the Data Link protocol layer is
      still bound to the HCI UART driver.
      
      Failure to perform this protocol check causes a race condition between
      the work queue hu->write_work running hci_uart_write_work() and the
      Data Link protocol layer being unbound (closed) in hci_uart_tty_close().
      
      Note hci_uart_tty_close() does have a "cancel_work_sync(&hu->write_work)"
      but it is ineffective because it cannot prevent work-items being added
      to hu->write_work after cancel_work_sync() has run.
      
      Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_tx_wakeup()
      which prevents scheduling of the work queue when HCI_UART_PROTO_READY
      is in the clear state. However, note a small race condition remains
      because the hci_uart_tx_wakeup() thread can run in parallel with the
      hci_uart_tty_close() thread so it is possible that a schedule of
      hu->write_work can occur when HCI_UART_PROTO_READY is cleared. A complete
      solution needs locking of the threads which is implemented in a future
      commit.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      2d6f1da1
    • D
      Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue() · 048e1bd3
      Dean Jenkins 提交于
      Before attempting to dequeue a Data Link protocol encapsulated message,
      check that the Data Link protocol is still bound to the HCI UART driver.
      This makes the code consistent with the usage of the other proto
      function pointers.
      
      Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_dequeue()
      and return NULL if the Data Link protocol is not bound.
      
      This is needed for robustness as there is a scheduling race condition.
      hci_uart_write_work() is scheduled to run via work queue hu->write_work
      from hci_uart_tx_wakeup(). Therefore, there is a delay between
      scheduling hci_uart_write_work() to run and hci_uart_dequeue() running
      whereby the Data Link protocol layer could become unbound during the
      scheduling delay. In this case, without the check, the call to the
      unbound Data Link protocol layer dequeue function can crash.
      
      It is noted that hci_uart_tty_close() has a
      "cancel_work_sync(&hu->write_work)" statement but this only reduces
      the window of the race condition because it is possible for a new
      work-item to be added to work queue hu->write_work after the call to
      cancel_work_sync(). For example, Data Link layer retransmissions can
      be added to the work queue after the cancel_work_sync() has finished.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      048e1bd3
    • D
      Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame() · ab00f89f
      Dean Jenkins 提交于
      Before attempting to send a HCI message, check that the Data Link
      protocol is still bound to the HCI UART driver. This makes the code
      consistent with the usage of the other proto function pointers.
      
      Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_send_frame()
      and return -EUNATCH if the Data Link protocol is not bound.
      
      This also allows hci_send_frame() to report the error of an unbound
      Data Link protocol layer. Therefore, it assists with diagnostics into
      why HCI messages are being sent when the Data Link protocol is not
      bound and avoids potential crashes.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ab00f89f
  4. 22 4月, 2017 3 次提交
  5. 14 4月, 2017 1 次提交
  6. 13 4月, 2017 2 次提交
  7. 24 9月, 2016 1 次提交
  8. 20 9月, 2016 1 次提交
  9. 10 7月, 2016 1 次提交
    • M
      Bluetooth: Rename HCI_BREDR into HCI_PRIMARY · ca8bee5d
      Marcel Holtmann 提交于
      The HCI_BREDR naming is confusing since it actually stands for Primary
      Bluetooth Controller. Which is a term that has been used in the latest
      standard. However from a legacy point of view there only really have
      been Basic Rate (BR) and Enhanced Data Rate (EDR). Recent versions of
      Bluetooth introduced Low Energy (LE) and made this terminology a little
      bit confused since Dual Mode Controllers include BR/EDR and LE. To
      simplify this the name HCI_PRIMARY stands for the Primary Controller
      which can be a single mode or dual mode controller.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      ca8bee5d
  10. 09 4月, 2016 1 次提交
  11. 24 2月, 2016 1 次提交
  12. 10 12月, 2015 1 次提交
  13. 20 11月, 2015 1 次提交
  14. 21 10月, 2015 1 次提交
  15. 05 10月, 2015 2 次提交
  16. 24 9月, 2015 1 次提交
    • F
      Bluetooth: Remove useless rx_lock spinlock · 7649faff
      Frederic Danis 提交于
      rx_lock spinlock is only used in hci_uart_tty_receive() which is the
      receive_buf ldisc callback.
      
      hci_uart_tty_receive() is protected from re-entrance by its only
      caller (flush_to_ldisc() in drivers/tty/tty_buffer.c) which held a
      mutex (buf->lock) for this section.
      This lock allows "safe use of the line discipline's receive_buf()
      method by excluding the buffer work and any pending flush from using
      the flip buffer." (comments from tty_buffer_lock_exclusive() in
      drivers/tty/tty_buffer.c)
      
      So, no need to double protect this resource with rx_lock.
      Signed-off-by: NFrederic Danis <frederic.danis@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      7649faff
  17. 11 8月, 2015 1 次提交
  18. 27 7月, 2015 1 次提交
  19. 23 7月, 2015 1 次提交
  20. 18 6月, 2015 2 次提交
  21. 06 6月, 2015 2 次提交
  22. 08 4月, 2015 11 次提交