1. Oct 14, 2023
  2. Oct 12, 2023
    • Ziyang Xuan's avatar
      Bluetooth: Fix a refcnt underflow problem for hci_conn · c7f59461
      Ziyang Xuan authored
      Syzbot reports a warning as follows:
      
      WARNING: CPU: 1 PID: 26946 at net/bluetooth/hci_conn.c:619
      hci_conn_timeout+0x122/0x210 net/bluetooth/hci_conn.c:619
      ...
      Call Trace:
       <TASK>
       process_one_work+0x884/0x15c0 kernel/workqueue.c:2630
       process_scheduled_works kernel/workqueue.c:2703 [inline]
       worker_thread+0x8b9/0x1290 kernel/workqueue.c:2784
       kthread+0x33c/0x440 kernel/kthread.c:388
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
       </TASK>
      
      It is because the HCI_EV_SIMPLE_PAIR_COMPLETE event handler drops
      hci_conn directly without check Simple Pairing whether be enabled. But
      the Simple Pairing process can only be used if both sides have the
      support enabled in the host stack.
      
      Add hci_conn_ssp_enabled() for hci_conn in HCI_EV_IO_CAPA_REQUEST and
      HCI_EV_SIMPLE_PAIR_COMPLETE event handlers to fix the problem.
      
      Fixes: 0493684e
      
       ("[Bluetooth] Disable disconnect timer during Simple Pairing")
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      c7f59461
    • Pauli Virtanen's avatar
      Bluetooth: hci_sync: always check if connection is alive before deleting · a239110e
      Pauli Virtanen authored
      In hci_abort_conn_sync it is possible that conn is deleted concurrently
      by something else, also e.g. when waiting for hdev->lock.  This causes
      double deletion of the conn, so UAF or conn_hash.list corruption.
      
      Fix by having all code paths check that the connection is still in
      conn_hash before deleting it, while holding hdev->lock which prevents
      any races.
      
      Log (when powering off while BAP streaming, occurs rarely):
      =======================================================================
      kernel BUG at lib/list_debug.c:56!
      ...
       ? __list_del_entry_valid (lib/list_debug.c:56)
       hci_conn_del (net/bluetooth/hci_conn.c:154) bluetooth
       hci_abort_conn_sync (net/bluetooth/hci_sync.c:5415) bluetooth
       ? __pfx_hci_abort_conn_sync+0x10/0x10 [bluetooth]
       ? lock_release+0x1d5/0x3c0
       ? hci_disconnect_all_sync.constprop.0+0xb2/0x230 [bluetooth]
       ? __pfx_lock_release+0x10/0x10
       ? __kmem_cache_free+0x14d/0x2e0
       hci_disconnect_all_sync.constprop.0+0xda/0x230 [bluetooth]
       ? __pfx_hci_disconnect_all_sync.constprop.0+0x10/0x10 [bluetooth]
       ? hci_clear_adv_sync+0x14f/0x170 [bluetooth]
       ? __pfx_set_powered_sync+0x10/0x10 [bluetooth]
       hci_set_powered_sync+0x293/0x450 [bluetooth]
      =======================================================================
      
      Fixes: 94d9ba9f
      
       ("Bluetooth: hci_sync: Fix UAF in hci_disconnect_all_sync")
      Signed-off-by: default avatarPauli Virtanen <pav@iki.fi>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      a239110e
    • Lee, Chun-Yi's avatar
      Bluetooth: Reject connection with the device which has same BD_ADDR · 1ffc6f8c
      Lee, Chun-Yi authored
      This change is used to relieve CVE-2020-26555. The description of
      the CVE:
      
      Bluetooth legacy BR/EDR PIN code pairing in Bluetooth Core Specification
      1.0B through 5.2 may permit an unauthenticated nearby device to spoof
      the BD_ADDR of the peer device to complete pairing without knowledge
      of the PIN. [1]
      
      The detail of this attack is in IEEE paper:
      BlueMirror: Reflections on Bluetooth Pairing and Provisioning Protocols
      [2]
      
      It's a reflection attack. The paper mentioned that attacker can induce
      the attacked target to generate null link key (zero key) without PIN
      code. In BR/EDR, the key generation is actually handled in the controller
      which is below HCI.
      
      A condition of this attack is that attacker should change the
      BR_ADDR of his hacking device (Host B) to equal to the BR_ADDR with
      the target device being attacked (Host A).
      
      Thus, we reject the connection with device which has same BD_ADDR
      both on HCI_Create_Connection and HCI_Connection_Request to prevent
      the attack. A similar implementation also shows in btstack project.
      [3][4]
      
      Cc: stable@vger.kernel.org
      Link: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26555 [1]
      Link: https://ieeexplore.ieee.org/abstract/document/9474325/authors#authors [2]
      Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L3523 [3]
      Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L7297
      
       [4]
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      1ffc6f8c
    • Lee, Chun-Yi's avatar
      Bluetooth: hci_event: Ignore NULL link key · 33155c4a
      Lee, Chun-Yi authored
      This change is used to relieve CVE-2020-26555. The description of the
      CVE:
      
      Bluetooth legacy BR/EDR PIN code pairing in Bluetooth Core Specification
      1.0B through 5.2 may permit an unauthenticated nearby device to spoof
      the BD_ADDR of the peer device to complete pairing without knowledge
      of the PIN. [1]
      
      The detail of this attack is in IEEE paper:
      BlueMirror: Reflections on Bluetooth Pairing and Provisioning Protocols
      [2]
      
      It's a reflection attack. The paper mentioned that attacker can induce
      the attacked target to generate null link key (zero key) without PIN
      code. In BR/EDR, the key generation is actually handled in the controller
      which is below HCI.
      
      Thus, we can ignore null link key in the handler of "Link Key Notification
      event" to relieve the attack. A similar implementation also shows in
      btstack project. [3]
      
      v3: Drop the connection when null link key be detected.
      
      v2:
      - Used Link: tag instead of Closes:
      - Used bt_dev_dbg instead of BT_DBG
      - Added Fixes: tag
      
      Cc: stable@vger.kernel.org
      Fixes: 55ed8ca1 ("Bluetooth: Implement link key handling for the management interface")
      Link: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26555 [1]
      Link: https://ieeexplore.ieee.org/abstract/document/9474325/authors#authors [2]
      Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L3722
      
       [3]
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      33155c4a
    • Iulia Tanasescu's avatar
      Bluetooth: ISO: Fix invalid context error · acab8ff2
      Iulia Tanasescu authored
      
      
      This moves the hci_le_terminate_big_sync call from rx_work
      to cmd_sync_work, to avoid calling sleeping function from
      an invalid context.
      
      Reported-by: default avatar <syzbot+c715e1bd8dfbcb1ab176@syzkaller.appspotmail.com>
      Fixes: a0bfde16
      
       ("Bluetooth: ISO: Add support for connecting multiple BISes")
      Signed-off-by: default avatarIulia Tanasescu <iulia.tanasescu@nxp.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      acab8ff2
    • Arkadiusz Bokowy's avatar
      Bluetooth: vhci: Fix race when opening vhci device · 92d4abd6
      Arkadiusz Bokowy authored
      
      
      When the vhci device is opened in the two-step way, i.e.: open device
      then write a vendor packet with requested controller type, the device
      shall respond with a vendor packet which includes HCI index of created
      interface.
      
      When the virtual HCI is created, the host sends a reset request to the
      controller. This request is processed by the vhci_send_frame() function.
      However, this request is send by a different thread, so it might happen
      that this HCI request will be received before the vendor response is
      queued in the read queue. This results in the HCI vendor response and
      HCI reset request inversion in the read queue which leads to improper
      behavior of btvirt:
      
      > dmesg
      [1754256.640122] Bluetooth: MGMT ver 1.22
      [1754263.023806] Bluetooth: MGMT ver 1.22
      [1754265.043775] Bluetooth: hci1: Opcode 0x c03 failed: -110
      
      In order to synchronize vhci two-step open/setup process with virtual
      HCI initialization, this patch adds internal lock when queuing data in
      the vhci_send_frame() function.
      
      Signed-off-by: default avatarArkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      92d4abd6
  3. Oct 11, 2023
  4. Oct 10, 2023
  5. Oct 09, 2023
  6. Oct 08, 2023