1. 02 Jun, 2014 2 commits
    • Jukka Taimisto's avatar
      Bluetooth: Fix L2CAP deadlock · 8a96f3cd
      Jukka Taimisto authored
      -[0x01 Introduction
      
      We have found a programming error causing a deadlock in Bluetooth subsystem
      of Linux kernel. The problem is caused by missing release_sock() call when
      L2CAP connection creation fails due full accept queue.
      
      The issue can be reproduced with 3.15-rc5 kernel and is also present in
      earlier kernels.
      
      -[0x02 Details
      
      The problem occurs when multiple L2CAP connections are created to a PSM which
      contains listening socket (like SDP) and left pending, for example,
      configuration (the underlying ACL link is not disconnected between
      connections).
      
      When L2CAP connection request is received and listening socket is found the
      l2cap_sock_new_connection_cb() function (net/bluetooth/l2cap_sock.c) is called.
      This function locks the 'parent' socket and then checks if the accept queue
      is full.
      
      1178         lock_sock(parent);
      1179
      1180         /* Check for backlog size */
      1181         if (sk_acceptq_is_full(parent)) {
      1182                 BT_DBG("backlog full %d", parent->sk_ack_backlog);
      1183                 return NULL;
      1184         }
      
      If case the accept queue is full NULL is returned, but the 'parent' socket
      is not released. Thus when next L2CAP connection request is received the code
      blocks on lock_sock() since the parent is still locked.
      
      Also note that for connections already established and waiting for
      configuration to complete a timeout will occur and l2cap_chan_timeout()
      (net/bluetooth/l2cap_core.c) will be called. All threads calling this
      function will also be blocked waiting for the channel mutex since the thread
      which is waiting on lock_sock() alread holds the channel mutex.
      
      We were able to reproduce this by sending continuously L2CAP connection
      request followed by disconnection request containing invalid CID. This left
      the created connections pending configuration.
      
      After the deadlock occurs it is impossible to kill bluetoothd, btmon will not
      get any more data etc. requiring reboot to recover.
      
      -[0x03 Fix
      
      Releasing the 'parent' socket when l2cap_sock_new_connection_cb() returns NULL
      seems to fix the issue.
      Signed-off-by: default avatarJukka Taimisto <jtt@codenomicon.com>
      Reported-by: default avatarTommi Mäkilä <tmakila@codenomicon.com>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Cc: stable@vger.kernel.org
      8a96f3cd
    • Johan Hedberg's avatar
      Bluetooth: Fix missing check for FIPS security level · f3fb0b58
      Johan Hedberg authored
      When checking whether a legacy link key provides at least HIGH security
      level we also need to check for FIPS level which is one step above HIGH.
      This patch fixes a missing check in the hci_link_key_request_evt()
      function.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org
      f3fb0b58
  2. 01 Jun, 2014 1 commit
  3. 31 May, 2014 4 commits
  4. 27 May, 2014 1 commit
  5. 23 May, 2014 1 commit
  6. 20 May, 2014 6 commits
  7. 16 May, 2014 6 commits
  8. 09 May, 2014 2 commits
  9. 08 May, 2014 3 commits
    • Petri Gynther's avatar
      Bluetooth: btusb: Add Broadcom patch RAM support · 10d4c673
      Petri Gynther authored
      After hardware reset, some BCM Bluetooth adapters obtain their initial firmware
      from OTPROM chip. Once this initial firmware is running, the firmware can be
      further upgraded over HCI interface with .hcd files provided by Broadcom. This
      is also known as "patch RAM" support. This change implements that.
      
      If the .hcd file is not found in /lib/firmware, BCM Bluetooth adapter continues
      to operate with the initial firmware. Sample kernel log:
        hotplug: sys=firmware act=add fw=brcm/BCM20702A0-0a5c-22be.hcd dev=...
        Bluetooth: hci0: BCM: patch brcm/BCM20702A0-0a5c-22be.hcd not found
      
      If the .hcd file is found, btusb driver pushes it to the BCM Bluetooth adapter and
      it starts using the new firmware. Sample kernel log:
        hotplug: sys=firmware act=add fw=brcm/BCM20702A0-0a5c-22be.hcd dev=...
        Bluetooth: hci0: BCM: patching hci_ver=06 hci_rev=1000 lmp_ver=06 lmp_subver=220e
        Bluetooth: hci0: BCM: firmware hci_ver=06 hci_rev=1389 lmp_ver=06 lmp_subver=220e
      
      Above, we can see that hci_rev goes from 1000 to 1389 as a result of the upgrade.
      Signed-off-by: default avatarPetri Gynther <pgynther@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      10d4c673
    • Andrzej Kaczmarek's avatar
      Bluetooth: Store RSSI for connection · 5ae76a94
      Andrzej Kaczmarek authored
      This patch adds support to store RSSI for connection when reply for
      HCI_Read_RSSI is received.
      Signed-off-by: default avatarAndrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      5ae76a94
    • Johan Hedberg's avatar
      Bluetooth: Add support for SMP Invalid Parameters error code · 38e4a915
      Johan Hedberg authored
      The Invalid Parameters error code is used to indicate that the command
      length is invalid or that a parameter is outside of the specified range.
      This error code wasn't clearly specified in the Bluetooth 4.0
      specification but since 4.1 this has been fixed.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      38e4a915
  10. 06 May, 2014 1 commit
  11. 24 Apr, 2014 3 commits
  12. 11 Apr, 2014 4 commits
    • Mikel Astiz's avatar
      Bluetooth: Request MITM Protection when initiator · b16c6604
      Mikel Astiz authored
      The GAP Specification gives the flexibility to decide whether MITM
      Protection is requested or not (Bluetooth Core Specification v4.0
      Volume 3, part C, section 6.5.3) when replying to an
      HCI_EV_IO_CAPA_REQUEST event.
      
      The recommendation is *not* to set this flag "unless the security
      policy of an available local service requires MITM Protection"
      (regardless of the bonding type). However, the kernel doesn't
      necessarily have this information and therefore the safest choice is
      to always use MITM Protection, also for General Bonding.
      
      This patch changes the behavior for the General Bonding initiator
      role, always requesting MITM Protection even if no high security level
      is used. Depending on the remote capabilities, the protection might
      not be actually used, and we will accept this locally unless of course
      a high security level was originally required.
      
      Note that this was already done for Dedicated Bonding. No-Bonding is
      left unmodified because MITM Protection is normally not desired in
      these cases.
      Signed-off-by: default avatarMikel Astiz <mikel.astiz@bmw-carit.de>
      Signed-off-by: default avatarTimo Mueller <timo.mueller@bmw-carit.de>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      b16c6604
    • Timo Mueller's avatar
      Bluetooth: Use MITM Protection when IO caps allow it · 7e74170a
      Timo Mueller authored
      When responding to a remotely-initiated pairing procedure, a MITM
      protected SSP associaton model can be used for pairing if both local
      and remote IO capabilities are set to something other than
      NoInputNoOutput, regardless of the bonding type (Dedicated or
      General).
      
      This was already done for Dedicated Bonding but this patch proposes to
      use the same policy for General Bonding as well.
      
      The GAP Specification gives the flexibility to decide whether MITM
      Protection is used ot not (Bluetooth Core Specification v4.0 Volume 3,
      part C, section 6.5.3).
      
      Note however that the recommendation is *not* to set this flag "unless
      the security policy of an available local service requires MITM
      Protection" (for both Dedicated and General Bonding). However, as we are
      already requiring MITM for Dedicated Bonding, we will follow this
      behaviour also for General Bonding.
      Signed-off-by: default avatarTimo Mueller <timo.mueller@bmw-carit.de>
      Signed-off-by: default avatarMikel Astiz <mikel.astiz@bmw-carit.de>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      7e74170a
    • Mikel Astiz's avatar
      Bluetooth: Refactor code for outgoing dedicated bonding · 6fd6b915
      Mikel Astiz authored
      Do not always set the MITM protection requirement by default in the
      field conn->auth_type, since this will be added later in
      hci_io_capa_request_evt(), as part of the requirements specified in
      HCI_OP_IO_CAPABILITY_REPLY.
      
      This avoids a hackish exception for the auto-reject case, but doesn't
      change the behavior of the code at all.
      Signed-off-by: default avatarMikel Astiz <mikel.astiz@bmw-carit.de>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      6fd6b915
    • Mikel Astiz's avatar
      Bluetooth: Refactor hci_get_auth_req() · b7f94c88
      Mikel Astiz authored
      Refactor the code without changing its behavior by handling the
      no-bonding cases first followed by General Bonding.
      Signed-off-by: default avatarMikel Astiz <mikel.astiz@bmw-carit.de>
      Signed-off-by: default avatarTimo Mueller <timo.mueller@bmw-carit.de>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      b7f94c88
  13. 29 Mar, 2014 2 commits
  14. 28 Mar, 2014 4 commits