1. 25 4月, 2017 1 次提交
  2. 08 12月, 2016 1 次提交
  3. 20 9月, 2016 1 次提交
    • S
      Bluetooth: Fix not registering BR/EDR SMP channel with force_bredr flag · 83ebb9ec
      Szymon Janc 提交于
      If force_bredr is set SMP BR/EDR channel should also be for non-SC
      capable controllers. Since hcidev flag is persistent wrt power toggle
      it can be already set when calling smp_register(). This resulted in
      SMP BR/EDR channel not being registered even if HCI_FORCE_BREDR_SMP
      flag was set.
      
      This also fix NULL pointer dereference when trying to disable
      force_bredr after power cycle.
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000388
      IP: [<ffffffffc0493ad8>] smp_del_chan+0x18/0x80 [bluetooth]
      
      Call Trace:
      [<ffffffffc04950ca>] force_bredr_smp_write+0xba/0x100 [bluetooth]
      [<ffffffff8133be14>] full_proxy_write+0x54/0x90
      [<ffffffff81245967>] __vfs_write+0x37/0x160
      [<ffffffff813617f7>] ? selinux_file_permission+0xd7/0x110
      [<ffffffff81356fbd>] ? security_file_permission+0x3d/0xc0
      [<ffffffff810eb5b2>] ? percpu_down_read+0x12/0x50
      [<ffffffff812462a5>] vfs_write+0xb5/0x1a0
      [<ffffffff812476f5>] SyS_write+0x55/0xc0
      [<ffffffff817eb872>] entry_SYSCALL_64_fastpath+0x1a/0xa4
      Code: 48 8b 45 f0 eb c1 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f
            44 00 00 f6 05 c6 3b 02 00 04 55 48 89 e5 41 54 53 49 89 fc 75
            4b
            <49> 8b 9c 24 88 03 00 00 48 85 db 74 31 49 c7 84 24 88 03 00 00
      RIP  [<ffffffffc0493ad8>] smp_del_chan+0x18/0x80 [bluetooth]
      RSP <ffff8802aee3bd90>
      CR2: 0000000000000388
      Signed-off-by: NSzymon Janc <szymon.janc@codecoup.pl>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      83ebb9ec
  4. 08 7月, 2016 1 次提交
  5. 29 1月, 2016 1 次提交
    • J
      Bluetooth: Fix incorrect removing of IRKs · cff10ce7
      Johan Hedberg 提交于
      The commit cad20c27 was supposed to
      fix handling of devices first using public addresses and then
      switching to RPAs after pairing. Unfortunately it missed a couple of
      key places in the code.
      
      1. When evaluating which devices should be removed from the existing
      white list we also need to consider whether we have an IRK for them or
      not, i.e. a call to hci_find_irk_by_addr() is needed.
      
      2. In smp_notify_keys() we should not be requiring the knowledge of
      the RPA, but should simply keep the IRK around if the other conditions
      require it.
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org # 4.4+
      cff10ce7
  6. 27 1月, 2016 1 次提交
  7. 12 11月, 2015 1 次提交
    • J
      Bluetooth: Fix l2cap_chan leak in SMP · 7883746b
      Johan Hedberg 提交于
      The L2CAP core expects channel implementations to manage the reference
      returned by the new_connection callback. With sockets this is already
      handled with each channel being tied to the corresponding socket. With
      SMP however there's no context to tie the pointer to in the
      smp_new_conn_cb function. The function can also not just drop the
      reference since it's the only one at that point.
      
      For fixed channels (like SMP) the code path inside the L2CAP core from
      new_connection() to ready() is short and straight-forwards. The
      crucial difference is that in ready() the implementation has access to
      the l2cap_conn that SMP needs associate its l2cap_chan. Instead of
      taking a new reference in smp_ready_cb() we can simply assume to
      already own the reference created in smp_new_conn_cb(), i.e. there is
      no need to call l2cap_chan_hold().
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org # 3.19+
      7883746b
  8. 22 10月, 2015 2 次提交
    • J
      Bluetooth: Fix crash in SMP when unpairing · c81d555a
      Johan Hedberg 提交于
      When unpairing the keys stored in hci_dev are removed. If SMP is
      ongoing the SMP context will also have references to these keys, so
      removing them from the hci_dev lists will make the pointers invalid.
      This can result in the following type of crashes:
      
       BUG: unable to handle kernel paging request at 6b6b6b6b
       IP: [<c11f26be>] __list_del_entry+0x44/0x71
       *pde = 00000000
       Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
       Modules linked in: hci_uart btqca btusb btintel btbcm btrtl hci_vhci rfcomm bluetooth_6lowpan bluetooth
       CPU: 0 PID: 723 Comm: kworker/u5:0 Not tainted 4.3.0-rc3+ #1379
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.1-20150318_183358- 04/01/2014
       Workqueue: hci0 hci_rx_work [bluetooth]
       task: f19da940 ti: f1a94000 task.ti: f1a94000
       EIP: 0060:[<c11f26be>] EFLAGS: 00010202 CPU: 0
       EIP is at __list_del_entry+0x44/0x71
       EAX: c0088d20 EBX: f30fcac0 ECX: 6b6b6b6b EDX: 6b6b6b6b
       ESI: f4b60000 EDI: c0088d20 EBP: f1a95d90 ESP: f1a95d8c
        DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
       CR0: 8005003b CR2: 6b6b6b6b CR3: 319e5000 CR4: 00000690
       Stack:
        f30fcac0 f1a95db0 f82dc3e1 f1bfc000 00000000 c106524f f1bfc000 f30fd020
        f1a95dc0 f1a95dd0 f82dcbdb f1a95de0 f82dcbdb 00000067 f1bfc000 f30fd020
        f1a95de0 f1a95df0 f82d1126 00000067 f82d1126 00000006 f30fd020 f1bfc000
       Call Trace:
        [<f82dc3e1>] smp_chan_destroy+0x192/0x240 [bluetooth]
        [<c106524f>] ? trace_hardirqs_on_caller+0x14e/0x169
        [<f82dcbdb>] smp_teardown_cb+0x47/0x64 [bluetooth]
        [<f82dcbdb>] ? smp_teardown_cb+0x47/0x64 [bluetooth]
        [<f82d1126>] l2cap_chan_del+0x5d/0x14d [bluetooth]
        [<f82d1126>] ? l2cap_chan_del+0x5d/0x14d [bluetooth]
        [<f82d40ef>] l2cap_conn_del+0x109/0x17b [bluetooth]
        [<f82d40ef>] ? l2cap_conn_del+0x109/0x17b [bluetooth]
        [<f82c0205>] ? hci_event_packet+0x5b1/0x2092 [bluetooth]
        [<f82d41aa>] l2cap_disconn_cfm+0x49/0x50 [bluetooth]
        [<f82d41aa>] ? l2cap_disconn_cfm+0x49/0x50 [bluetooth]
        [<f82c0228>] hci_event_packet+0x5d4/0x2092 [bluetooth]
        [<c1332c16>] ? skb_release_data+0x6a/0x95
        [<f82ce5d4>] ? hci_send_to_monitor+0xe7/0xf4 [bluetooth]
        [<c1409708>] ? _raw_spin_unlock_irqrestore+0x44/0x57
        [<f82b3bb0>] hci_rx_work+0xf1/0x28b [bluetooth]
        [<f82b3bb0>] ? hci_rx_work+0xf1/0x28b [bluetooth]
        [<c10635a0>] ? __lock_is_held+0x2e/0x44
        [<c104772e>] process_one_work+0x232/0x432
        [<c1071ddc>] ? rcu_read_lock_sched_held+0x50/0x5a
        [<c104772e>] ? process_one_work+0x232/0x432
        [<c1047d48>] worker_thread+0x1b8/0x255
        [<c1047b90>] ? rescuer_thread+0x23c/0x23c
        [<c104bb71>] kthread+0x91/0x96
        [<c14096a7>] ? _raw_spin_unlock_irq+0x27/0x44
        [<c1409d61>] ret_from_kernel_thread+0x21/0x30
        [<c104bae0>] ? kthread_parkme+0x1e/0x1e
      
      To solve the issue, introduce a new smp_cancel_pairing() API that can
      be used to clean up the SMP state before touching the hci_dev lists.
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c81d555a
    • J
      Bluetooth: Remove redundant (and possibly wrong) flag clearing · 1ede9868
      Johan Hedberg 提交于
      There's no need to clear the HCI_CONN_ENCRYPT_PEND flag in
      smp_failure. In fact, this may cause the encryption tracking to get
      out of sync as this has nothing to do with HCI activity.
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1ede9868
  9. 21 10月, 2015 1 次提交
  10. 17 9月, 2015 2 次提交
  11. 23 7月, 2015 1 次提交
  12. 12 6月, 2015 3 次提交
  13. 10 6月, 2015 1 次提交
  14. 09 6月, 2015 1 次提交
  15. 20 5月, 2015 1 次提交
  16. 02 4月, 2015 1 次提交
  17. 31 3月, 2015 1 次提交
  18. 18 3月, 2015 2 次提交
    • M
      Bluetooth: Fix potential NULL dereference in SMP channel setup · 63511f6d
      Marcel Holtmann 提交于
      When the allocation of the L2CAP channel for the BR/EDR security manager
      fails, then the smp variable might be NULL. In that case do not try to
      free the non-existing crypto contexts
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      63511f6d
    • J
      Bluetooth: Add workaround for broken OS X legacy SMP pairing · 19c5ce9c
      Johan Hedberg 提交于
      OS X version 10.10.2 (and possibly older versions) doesn't support LE
      Secure Connections but incorrectly copies all authentication request
      bits from a Security Request to its Pairing Request. The result is that
      an SC capable initiator (such as BlueZ) will think OS X intends to do SC
      when in fact it's incapable of it:
      
      < ACL Data TX: Handle 3585 flags 0x00 dlen 6
            SMP: Security Request (0x0b) len 1
              Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09)
      > ACL Data RX: Handle 3585 flags 0x02 dlen 11
            SMP: Pairing Request (0x01) len 6
              IO capability: KeyboardDisplay (0x04)
              OOB data: Authentication data not present (0x00)
              Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09)
              Max encryption key size: 16
              Initiator key distribution: EncKey (0x01)
              Responder key distribution: EncKey IdKey Sign (0x07)
      < ACL Data TX: Handle 3585 flags 0x00 dlen 11
            SMP: Pairing Response (0x02) len 6
              IO capability: NoInputNoOutput (0x03)
              OOB data: Authentication data not present (0x00)
              Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09)
              Max encryption key size: 16
              Initiator key distribution: EncKey (0x01)
              Responder key distribution: EncKey Sign (0x05)
      
      The pairing eventually fails when we get an unexpected Pairing Confirm
      PDU instead of a Public Key PDU:
      
      > ACL Data RX: Handle 3585 flags 0x02 dlen 21
            SMP: Pairing Confirm (0x03) len 16
              Confim value: bcc3bed31b8f313a78ec3cce32685faf
      
      It is only at this point that we can speculate that the remote doesn't
      really support SC. This patch creates a workaround for the just-works
      model, however the MITM case is unsolvable because the OS X user has
      already been requested to enter a PIN which we're now expected to
      randomly generate and show the user (i.e. a chicken-and-egg problem).
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      19c5ce9c
  19. 17 3月, 2015 9 次提交
  20. 16 3月, 2015 6 次提交
  21. 14 3月, 2015 1 次提交
  22. 13 3月, 2015 1 次提交