1. 11 7月, 2020 1 次提交
  2. 07 7月, 2020 1 次提交
  3. 23 6月, 2020 1 次提交
    • L
      Bluetooth: Disconnect if E0 is used for Level 4 · 8746f135
      Luiz Augusto von Dentz 提交于
      E0 is not allowed with Level 4:
      
      BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1319:
      
        '128-bit equivalent strength for link and encryption keys
         required using FIPS approved algorithms (E0 not allowed,
         SAFER+ not allowed, and P-192 not allowed; encryption key
         not shortened'
      
      SC enabled:
      
      > HCI Event: Read Remote Extended Features (0x23) plen 13
              Status: Success (0x00)
              Handle: 256
              Page: 1/2
              Features: 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x00
                Secure Simple Pairing (Host Support)
                LE Supported (Host)
                Secure Connections (Host Support)
      > HCI Event: Encryption Change (0x08) plen 4
              Status: Success (0x00)
              Handle: 256
              Encryption: Enabled with AES-CCM (0x02)
      
      SC disabled:
      
      > HCI Event: Read Remote Extended Features (0x23) plen 13
              Status: Success (0x00)
              Handle: 256
              Page: 1/2
              Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00
                Secure Simple Pairing (Host Support)
                LE Supported (Host)
      > HCI Event: Encryption Change (0x08) plen 4
              Status: Success (0x00)
              Handle: 256
              Encryption: Enabled with E0 (0x01)
      [May 8 20:23] Bluetooth: hci0: Invalid security: expect AES but E0 was used
      < HCI Command: Disconnect (0x01|0x0006) plen 3
              Handle: 256
              Reason: Authentication Failure (0x05)
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8746f135
  4. 18 6月, 2020 2 次提交
  5. 20 5月, 2020 1 次提交
  6. 18 5月, 2020 1 次提交
    • H
      Bluetooth: Add SCO fallback for invalid LMP parameters error · 56b5453a
      Hsin-Yu Chao 提交于
      Bluetooth PTS test case HFP/AG/ACC/BI-12-I accepts SCO connection
      with invalid parameter at the first SCO request expecting AG to
      attempt another SCO request with the use of "safe settings" for
      given codec, base on section 5.7.1.2 of HFP 1.7 specification.
      
      This patch addresses it by adding "Invalid LMP Parameters" (0x1e)
      to the SCO fallback case. Verified with below log:
      
      < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
              Handle: 256
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 13
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x0380
                3-EV3 may not be used
                2-EV5 may not be used
                3-EV5 may not be used
      > HCI Event: Command Status (0x0f) plen 4
            Setup Synchronous Connection (0x01|0x0028) ncmd 1
              Status: Success (0x00)
      > HCI Event: Number of Completed Packets (0x13) plen 5
              Num handles: 1
              Handle: 256
              Count: 1
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 1
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17
              Status: Invalid LMP Parameters / Invalid LL Parameters (0x1e)
              Handle: 0
              Address: 00:1B:DC:F2:21:59 (OUI 00-1B-DC)
              Link type: eSCO (0x02)
              Transmission interval: 0x00
              Retransmission window: 0x02
              RX packet length: 0
              TX packet length: 0
              Air mode: Transparent (0x03)
      < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
              Handle: 256
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 8
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x03c8
                EV3 may be used
                2-EV3 may not be used
                3-EV3 may not be used
                2-EV5 may not be used
                3-EV5 may not be used
      > HCI Event: Command Status (0x0f) plen 4
            Setup Synchronous Connection (0x01|0x0028) ncmd 1
              Status: Success (0x00)
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 5
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 1
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17
              Status: Success (0x00)
              Handle: 257
              Address: 00:1B:DC:F2:21:59 (OUI 00-1B-DC)
              Link type: eSCO (0x02)
              Transmission interval: 0x06
              Retransmission window: 0x04
              RX packet length: 30
              TX packet length: 30
              Air mode: Transparent (0x03)
      Signed-off-by: NHsin-Yu Chao <hychao@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      56b5453a
  7. 13 5月, 2020 1 次提交
    • S
      Bluetooth: Handle Inquiry Cancel error after Inquiry Complete · adf1d692
      Sonny Sasaka 提交于
      After sending Inquiry Cancel command to the controller, it is possible
      that Inquiry Complete event comes before Inquiry Cancel command complete
      event. In this case the Inquiry Cancel command will have status of
      Command Disallowed since there is no Inquiry session to be cancelled.
      This case should not be treated as error, otherwise we can reach an
      inconsistent state.
      
      Example of a btmon trace when this happened:
      
      < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0
      > HCI Event: Inquiry Complete (0x01) plen 1
              Status: Success (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            Inquiry Cancel (0x01|0x0002) ncmd 1
              Status: Command Disallowed (0x0c)
      Signed-off-by: NSonny Sasaka <sonnysasaka@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      adf1d692
  8. 28 4月, 2020 1 次提交
  9. 10 4月, 2020 1 次提交
  10. 05 4月, 2020 3 次提交
  11. 03 4月, 2020 1 次提交
  12. 25 3月, 2020 1 次提交
  13. 24 3月, 2020 1 次提交
  14. 12 3月, 2020 2 次提交
    • J
      Bluetooth: clean up connection in hci_cs_disconnect · b8d29052
      Joseph Hwang 提交于
      In bluetooth core specification 4.2,
      Vol 2, Part E, 7.8.9 LE Set Advertise Enable Command, it says
      
          The Controller shall continue advertising until ...
          or until a connection is created or ...
          In these cases, advertising is then disabled.
      
      Hence, advertising would be disabled before a connection is
      established. In current kernel implementation, advertising would
      be re-enabled when all connections are terminated.
      
      The correct disconnection flow looks like
      
        < HCI Command: Disconnect
      
        > HCI Event: Command Status
            Status: Success
      
        > HCI Event: Disconnect Complete
            Status: Success
      
      Specifically, the last Disconnect Complete Event would trigger a
      callback function hci_event.c:hci_disconn_complete_evt() to
      cleanup the connection and re-enable advertising when proper.
      
      However, sometimes, there might occur an exception in the controller
      when disconnection is being executed. The disconnection flow might
      then look like
      
        < HCI Command: Disconnect
      
        > HCI Event: Command Status
            Status: Unknown Connection Identifier
      
        Note that "> HCI Event: Disconnect Complete" is missing when such an
      exception occurs. This would result in advertising staying disabled
      forever since the connection in question is not cleaned up correctly.
      
      To fix the controller exception issue, we need to do some connection
      cleanup when the disconnect command status indicates an error.
      Signed-off-by: NJoseph Hwang <josephsih@chromium.org>
      Signed-off-by: NManish Mandlik <mmandlik@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b8d29052
    • A
      Bluetooth: Handle BR/EDR devices during suspend · 4f40afc6
      Abhishek Pandit-Subedi 提交于
      To handle BR/EDR devices, we first disable page scan and disconnect all
      connected devices. Once that is complete, we add event filters (for
      devices that can wake the system) and re-enable page scan.
      Signed-off-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4f40afc6
  15. 08 3月, 2020 1 次提交
  16. 04 3月, 2020 1 次提交
  17. 14 2月, 2020 1 次提交
    • H
      Bluetooth: secure bluetooth stack from bluedump attack · cee5f20f
      Howard Chung 提交于
      Attack scenario:
      1. A Chromebook (let's call this device A) is paired to a legitimate
         Bluetooth classic device (e.g. a speaker) (let's call this device
         B).
      2. A malicious device (let's call this device C) pretends to be the
         Bluetooth speaker by using the same BT address.
      3. If device A is not currently connected to device B, device A will
         be ready to accept connection from device B in the background
         (technically, doing Page Scan).
      4. Therefore, device C can initiate connection to device A
         (because device A is doing Page Scan) and device A will accept the
         connection because device A trusts device C's address which is the
         same as device B's address.
      5. Device C won't be able to communicate at any high level Bluetooth
         profile with device A because device A enforces that device C is
         encrypted with their common Link Key, which device C doesn't have.
         But device C can initiate pairing with device A with just-works
         model without requiring user interaction (there is only pairing
         notification). After pairing, device A now trusts device C with a
         new different link key, common between device A and C.
      6. From now on, device A trusts device C, so device C can at anytime
         connect to device A to do any kind of high-level hijacking, e.g.
         speaker hijack or mouse/keyboard hijack.
      
      Since we don't know whether the repairing is legitimate or not,
      leave the decision to user space if all the conditions below are met.
      - the pairing is initialized by peer
      - the authorization method is just-work
      - host already had the link key to the peer
      Signed-off-by: NHoward Chung <howardchung@google.com>
      Acked-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      cee5f20f
  18. 04 1月, 2020 2 次提交
  19. 05 9月, 2019 1 次提交
  20. 06 7月, 2019 2 次提交
    • C
      Bluetooth: validate BLE connection interval updates · c49a8682
      csonsino 提交于
      Problem: The Linux Bluetooth stack yields complete control over the BLE
      connection interval to the remote device.
      
      The Linux Bluetooth stack provides access to the BLE connection interval
      min and max values through /sys/kernel/debug/bluetooth/hci0/
      conn_min_interval and /sys/kernel/debug/bluetooth/hci0/conn_max_interval.
      These values are used for initial BLE connections, but the remote device
      has the ability to request a connection parameter update. In the event
      that the remote side requests to change the connection interval, the Linux
      kernel currently only validates that the desired value is within the
      acceptable range in the Bluetooth specification (6 - 3200, corresponding to
      7.5ms - 4000ms). There is currently no validation that the desired value
      requested by the remote device is within the min/max limits specified in
      the conn_min_interval/conn_max_interval configurations. This essentially
      leads to Linux yielding complete control over the connection interval to
      the remote device.
      
      The proposed patch adds a verification step to the connection parameter
      update mechanism, ensuring that the desired value is within the min/max
      bounds of the current connection. If the desired value is outside of the
      current connection min/max values, then the connection parameter update
      request is rejected and the negative response is returned to the remote
      device. Recall that the initial connection is established using the local
      conn_min_interval/conn_max_interval values, so this allows the Linux
      administrator to retain control over the BLE connection interval.
      
      The one downside that I see is that the current default Linux values for
      conn_min_interval and conn_max_interval typically correspond to 30ms and
      50ms respectively. If this change were accepted, then it is feasible that
      some devices would no longer be able to negotiate to their desired
      connection interval values. This might be remedied by setting the default
      Linux conn_min_interval and conn_max_interval values to the widest
      supported range (6 - 3200 / 7.5ms - 4000ms). This could lead to the same
      behavior as the current implementation, where the remote device could
      request to change the connection interval value to any value that is
      permitted by the Bluetooth specification, and Linux would accept the
      desired value.
      Signed-off-by: NCarey Sonsino <csonsino@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c49a8682
    • S
      Bluetooth: Add support for LE ping feature · 302975cb
      Spoorthi Ravishankar Koppad 提交于
      Changes made to add HCI Write Authenticated Payload timeout
      command for LE Ping feature.
      
      As per the Core Specification 5.0 Volume 2 Part E Section 7.3.94,
      the following code changes implements
      HCI Write Authenticated Payload timeout command for LE Ping feature.
      Signed-off-by: NSpoorthi Ravishankar Koppad <spoorthix.k@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      302975cb
  21. 06 5月, 2019 1 次提交
    • J
      Bluetooth: Ignore CC events not matching the last HCI command · f80c5dad
      João Paulo Rechi Vita 提交于
      This commit makes the kernel not send the next queued HCI command until
      a command complete arrives for the last HCI command sent to the
      controller. This change avoids a problem with some buggy controllers
      (seen on two SKUs of QCA9377) that send an extra command complete event
      for the previous command after the kernel had already sent a new HCI
      command to the controller.
      
      The problem was reproduced when starting an active scanning procedure,
      where an extra command complete event arrives for the LE_SET_RANDOM_ADDR
      command. When this happends the kernel ends up not processing the
      command complete for the following commmand, LE_SET_SCAN_PARAM, and
      ultimately behaving as if a passive scanning procedure was being
      performed, when in fact controller is performing an active scanning
      procedure. This makes it impossible to discover BLE devices as no device
      found events are sent to userspace.
      
      This problem is reproducible on 100% of the attempts on the affected
      controllers. The extra command complete event can be seen at timestamp
      27.420131 on the btmon logs bellow.
      
      Bluetooth monitor ver 5.50
      = Note: Linux version 5.0.0+ (x86_64)                                  0.352340
      = Note: Bluetooth subsystem version 2.22                               0.352343
      = New Index: 80:C5:F2:8F:87:84 (Primary,USB,hci0)               [hci0] 0.352344
      = Open Index: 80:C5:F2:8F:87:84                                 [hci0] 0.352345
      = Index Info: 80:C5:F2:8F:87:84 (Qualcomm)                      [hci0] 0.352346
      @ MGMT Open: bluetoothd (privileged) version 1.14             {0x0001} 0.352347
      @ MGMT Open: btmon (privileged) version 1.14                  {0x0002} 0.352366
      @ MGMT Open: btmgmt (privileged) version 1.14                {0x0003} 27.302164
      @ MGMT Command: Start Discovery (0x0023) plen 1       {0x0003} [hci0] 27.302310
              Address type: 0x06
                LE Public
                LE Random
      < HCI Command: LE Set Random Address (0x08|0x0005) plen 6   #1 [hci0] 27.302496
              Address: 15:60:F2:91:B2:24 (Non-Resolvable)
      > HCI Event: Command Complete (0x0e) plen 4                 #2 [hci0] 27.419117
            LE Set Random Address (0x08|0x0005) ncmd 1
              Status: Success (0x00)
      < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7  #3 [hci0] 27.419244
              Type: Active (0x01)
              Interval: 11.250 msec (0x0012)
              Window: 11.250 msec (0x0012)
              Own address type: Random (0x01)
              Filter policy: Accept all advertisement (0x00)
      > HCI Event: Command Complete (0x0e) plen 4                 #4 [hci0] 27.420131
            LE Set Random Address (0x08|0x0005) ncmd 1
              Status: Success (0x00)
      < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2      #5 [hci0] 27.420259
              Scanning: Enabled (0x01)
              Filter duplicates: Enabled (0x01)
      > HCI Event: Command Complete (0x0e) plen 4                 #6 [hci0] 27.420969
            LE Set Scan Parameters (0x08|0x000b) ncmd 1
              Status: Success (0x00)
      > HCI Event: Command Complete (0x0e) plen 4                 #7 [hci0] 27.421983
            LE Set Scan Enable (0x08|0x000c) ncmd 1
              Status: Success (0x00)
      @ MGMT Event: Command Complete (0x0001) plen 4        {0x0003} [hci0] 27.422059
            Start Discovery (0x0023) plen 1
              Status: Success (0x00)
              Address type: 0x06
                LE Public
                LE Random
      @ MGMT Event: Discovering (0x0013) plen 2             {0x0003} [hci0] 27.422067
              Address type: 0x06
                LE Public
                LE Random
              Discovery: Enabled (0x01)
      @ MGMT Event: Discovering (0x0013) plen 2             {0x0002} [hci0] 27.422067
              Address type: 0x06
                LE Public
                LE Random
              Discovery: Enabled (0x01)
      @ MGMT Event: Discovering (0x0013) plen 2             {0x0001} [hci0] 27.422067
              Address type: 0x06
                LE Public
                LE Random
              Discovery: Enabled (0x01)
      Signed-off-by: NJoão Paulo Rechi Vita <jprvita@endlessm.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      f80c5dad
  22. 24 4月, 2019 1 次提交
  23. 18 2月, 2019 1 次提交
  24. 19 12月, 2018 1 次提交
  25. 14 10月, 2018 1 次提交
  26. 27 9月, 2018 1 次提交
  27. 10 8月, 2018 1 次提交
  28. 06 8月, 2018 1 次提交
  29. 30 7月, 2018 6 次提交
    • J
      Bluetooth: Handle ADv set terminated event · acf0aeae
      Jaganath Kanakkassery 提交于
      This event comes after connection complete event for incoming
      connections. Since we now have different random address for
      each instance, conn resp address is assigned from this event.
      
      As of now only connection part is handled as we are not
      enabling duration or max num of events while starting ext adv.
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      acf0aeae
    • J
      Bluetooth: Implement Set ADV set random address · a73c046a
      Jaganath Kanakkassery 提交于
      This basically sets the random address for the adv instance
      Random address can be set only if the instance is created which
      is done in Set ext adv param.
      
      Random address and rpa expire timer and flags have been added
      to adv instance which will be used when the respective
      instance is scheduled.
      
      This introduces a hci_get_random_address() which returns the
      own address type and random address (rpa or nrpa) based
      on the instance flags and hdev flags. New function is required
      since own address type should be known before setting adv params
      but address can be set only after setting params.
      
      < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
              Advertising handle: 0x00
              Advertising random address: 3C:8E:56:9B:77:84 (OUI 3C-8E-56)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1
              Status: Success (0x00)
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a73c046a
    • J
      Bluetooth: Implement disable and removal of adv instance · 45b7749f
      Jaganath Kanakkassery 提交于
      If ext adv is enabled then use ext adv to disable as well.
      Also remove the adv set during LE disable.
      
      < HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 2
              Extended advertising: Disabled (0x00)
              Number of sets: Disable all sets (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
              Status: Success (0x00)
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      45b7749f
    • J
      Bluetooth: Use Set ext adv/scan rsp data if controller supports · a0fb3726
      Jaganath Kanakkassery 提交于
      This patch implements Set Ext Adv data and Set Ext Scan rsp data
      if controller support extended advertising.
      
      Currently the operation is set as Complete data and fragment
      preference is set as no fragment
      
      < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 35
              Handle: 0x00
              Operation: Complete extended advertising data (0x03)
              Fragment preference: Minimize fragmentation (0x01)
              Data length: 0x15
              16-bit Service UUIDs (complete): 2 entries
                Heart Rate (0x180d)
                Battery Service (0x180f)
              Name (complete): Test LE
              Company: Google (224)
                Data: 0102
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
              Status: Success (0x00)
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a0fb3726
    • J
      Bluetooth: Impmlement extended adv enable · de181e88
      Jaganath Kanakkassery 提交于
      This patch basically replaces legacy adv with extended adv
      based on the controller support. Currently there is no
      design change. ie only one adv set will be enabled at a time.
      
      This also adds tx_power in instance and store whatever returns
      from Set_ext_parameter, use the same in adv data as well.
      For instance 0 tx_power is stored in hdev only.
      
      < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25
              Handle: 0x00
              Properties: 0x0010
                Use legacy advertising PDUs: ADV_NONCONN_IND
              Min advertising interval: 1280.000 msec (0x0800)
              Max advertising interval: 1280.000 msec (0x0800)
              Channel map: 37, 38, 39 (0x07)
              Own address type: Random (0x01)
              Peer address type: Public (0x00)
              Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
              Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
              TX power: 127 dbm (0x7f)
              Primary PHY: LE 1M (0x01)
              Secondary max skip: 0x00
              Secondary PHY: LE 1M (0x01)
              SID: 0x00
              Scan request notifications: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 5
            LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1
              Status: Success (0x00)
              TX power (selected): 7 dbm (0x07)
      < HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
              Extended advertising: Enabled (0x01)
              Number of sets: 1 (0x01)
              Entry 0
                Handle: 0x00
                Duration: 0 ms (0x00)
                Max ext adv events: 0
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
              Status: Success (0x00)
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      de181e88
    • J
      Bluetooth: Read no of adv sets during init · 6b49bcb4
      Jaganath Kanakkassery 提交于
      This patch reads the number of advertising sets in the controller
      during init and save it in hdev.
      Signed-off-by: NJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6b49bcb4