1. 04 Aug, 2018 1 commit
  2. 03 Aug, 2018 19 commits
  3. 01 Aug, 2018 1 commit
    • Mark Salyzyn's avatar
      Bluetooth: hidp: buffer overflow in hidp_process_report · 7992c188
      Mark Salyzyn authored
      CVE-2018-9363
      
      The buffer length is unsigned at all layers, but gets cast to int and
      checked in hidp_process_report and can lead to a buffer overflow.
      Switch len parameter to unsigned int to resolve issue.
      
      This affects 3.18 and newer kernels.
      Signed-off-by: default avatarMark Salyzyn <salyzyn@android.com>
      Fixes: a4b1b587 ("HID: Bluetooth: hidp: make sure input buffers are big enough")
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: linux-bluetooth@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: security@kernel.org
      Cc: kernel-team@android.com
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      7992c188
  4. 30 Jul, 2018 18 commits
    • Marcel Holtmann's avatar
      Bluetooth: hidp: Fix handling of strncpy for hid->name information · b3cadaa4
      Marcel Holtmann authored
      This fixes two issues with setting hid->name information.
      
        CC      net/bluetooth/hidp/core.o
      In function ‘hidp_setup_hid’,
          inlined from ‘hidp_session_dev_init’ at net/bluetooth/hidp/core.c:815:9,
          inlined from ‘hidp_session_new’ at net/bluetooth/hidp/core.c:953:8,
          inlined from ‘hidp_connection_add’ at net/bluetooth/hidp/core.c:1366:8:
      net/bluetooth/hidp/core.c:778:2: warning: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127 [-Wstringop-truncation]
        strncpy(hid->name, req->name, sizeof(req->name) - 1);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
        CC      net/bluetooth/hidp/core.o
      net/bluetooth/hidp/core.c: In function ‘hidp_setup_hid’:
      net/bluetooth/hidp/core.c:778:38: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
        strncpy(hid->name, req->name, sizeof(req->name));
                                            ^
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      b3cadaa4
    • Sean Wang's avatar
      Bluetooth: Add new quirk for non-persistent setup settings · 740011cf
      Sean Wang authored
      Add a new quirk HCI_QUIRK_NON_PERSISTENT_SETUP allowing that a quirk that
      runs setup() after every open() and not just after the first open().
      Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      740011cf
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement secondary advertising on different PHYs · 85a721a8
      Jaganath Kanakkassery authored
      This patch adds support for advertising in primary and secondary
      channel on different PHYs. User can add the phy preference in
      the flag based on which phy type will be added in extended
      advertising parameter would be set.
      
      @ MGMT Command: Add Advertising (0x003e) plen 11
              Instance: 1
              Flags: 0x00000200
                Advertise in CODED on Secondary channel
              Duration: 0
              Timeout: 0
              Advertising data length: 0
              Scan response length: 0
      < 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)
      < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25
              Handle: 0x00
              Properties: 0x0000
              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 Coded (0x03)
              Secondary max skip: 0x00
              Secondary PHY: LE Coded (0x03)
              SID: 0x00
              Scan request notifications: Disabled (0x00)
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      85a721a8
    • Jaganath Kanakkassery's avatar
      Bluetooth: Handle ADv set terminated event · acf0aeae
      Jaganath Kanakkassery authored
      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: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      acf0aeae
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement Set ADV set random address · a73c046a
      Jaganath Kanakkassery authored
      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: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      a73c046a
    • Jaganath Kanakkassery's avatar
      Bluetooth: Use ext adv for directed adv · 075e40b7
      Jaganath Kanakkassery authored
      This patch does extended advertising for directed advertising
      if the controller supportes. Instance 0 is used for directed
      advertising.
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      075e40b7
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement disable and removal of adv instance · 45b7749f
      Jaganath Kanakkassery authored
      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: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      45b7749f
    • Jaganath Kanakkassery's avatar
      Bluetooth: Use Set ext adv/scan rsp data if controller supports · a0fb3726
      Jaganath Kanakkassery authored
      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: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      a0fb3726
    • Jaganath Kanakkassery's avatar
      Bluetooth: Impmlement extended adv enable · de181e88
      Jaganath Kanakkassery authored
      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: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      de181e88
    • Jaganath Kanakkassery's avatar
      Bluetooth: Read no of adv sets during init · 6b49bcb4
      Jaganath Kanakkassery authored
      This patch reads the number of advertising sets in the controller
      during init and save it in hdev.
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      6b49bcb4
    • Jaganath Kanakkassery's avatar
      Bluetooth: Use selected PHYs in extended connect · 4e6e99e9
      Jaganath Kanakkassery authored
      Use the selected PHYs by Set PHY Configuration management command
      in extended create connection.
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      4e6e99e9
    • Jaganath Kanakkassery's avatar
      Bluetooth: Handle extended ADV PDU types · b2cc9761
      Jaganath Kanakkassery authored
      This patch defines the extended ADV types and handle it in ADV report.
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      b2cc9761
    • Jaganath Kanakkassery's avatar
      Bluetooth: Set Scan PHYs based on selected PHYs by user · 45bdd86e
      Jaganath Kanakkassery authored
      Use the PHYs selected in Set Phy Configuration management command
      while scanning.
      
      < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 13
              Own address type: Random (0x01)
              Filter policy: Accept all advertisement (0x00)
              PHYs: 0x05
              Entry 0: LE 1M
                Type: Active (0x01)
                Interval: 11.250 msec (0x0012)
                Window: 11.250 msec (0x0012)
              Entry 1: LE Coded
                Type: Active (0x01)
                Interval: 11.250 msec (0x0012)
                Window: 11.250 msec (0x0012)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
              Status: Success (0x00)
      < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6
              Extended scan: Enabled (0x01)
              Filter duplicates: Enabled (0x01)
              Duration: 0 msec (0x0000)
              Period: 0.00 sec (0x0000)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
              Status: Success (0x00)
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      45bdd86e
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement PHY changed event · b7c23df8
      Jaganath Kanakkassery authored
      This defines and implement phy changed event and send it to user
      whenever selected PHYs changes using SET_PHY_CONFIGURATION.
      
      This will be also trigerred when BREDR pkt_type is changed using
      the legacy ioctl HCISETPTYPE.
      
      @ MGMT Command: Set PHY Configuration (0x0045) plen 4
      		Selected PHYs: 0x7fff
      		  BR 1M 1SLOT
      		  BR 1M 3SLOT
      		  BR 1M 5SLOT
      		  EDR 2M 1SLOT
      		  EDR 2M 3SLOT
      		  EDR 2M 5SLOT
      		  EDR 3M 1SLOT
      		  EDR 3M 3SLOT
      		  EDR 3M 5SLOT
      		  LE 1M TX
      		  LE 1M RX
      		  LE 2M TX
      		  LE 2M RX
      		  LE CODED TX
      		  LE CODED RX
      < HCI Command: LE Set Default PHY (0x08|0x0031) plen 3
      		All PHYs preference: 0x00
      		TX PHYs preference: 0x07
      		  LE 1M
      		  LE 2M
      		  LE Coded
      		RX PHYs preference: 0x07
      		  LE 1M
      		  LE 2M
      		  LE Coded
      > HCI Event: Command Complete (0x0e) plen 4
      	  LE Set Default PHY (0x08|0x0031) ncmd 1
      		Status: Success (0x00)
      @ MGMT Event: Command Complete (0x0001) plen 3
      	  Set PHY Configuration (0x0045) plen 0
      		Status: Success (0x00)
      @ MGMT Event: PHY Configuration Changed (0x0026) plen 4
      		Selected PHYs: 0x7fff
      		  BR 1M 1SLOT
      		  BR 1M 3SLOT
      		  BR 1M 5SLOT
      		  EDR 2M 1SLOT
      		  EDR 2M 3SLOT
      		  EDR 2M 5SLOT
      		  EDR 3M 1SLOT
      		  EDR 3M 3SLOT
      		  EDR 3M 5SLOT
      		  LE 1M TX
      		  LE 1M RX
      		  LE 2M TX
      		  LE 2M RX
      		  LE CODED TX
      		  LE CODED RX
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      b7c23df8
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement Set PHY Confguration command · 0314f286
      Jaganath Kanakkassery authored
      This enables user to set phys which will be used in all subsequent
      connections. Also host will use the same in LE scanning as well.
      
      @ MGMT Command: Set PHY Configuration (0x0045) plen 4
              Selected PHYs: 0x7fff
                BR 1M 1SLOT
                BR 1M 3SLOT
                BR 1M 5SLOT
                EDR 2M 1SLOT
                EDR 2M 3SLOT
                EDR 2M 5SLOT
                EDR 3M 1SLOT
                EDR 3M 3SLOT
                EDR 3M 5SLOT
                LE 1M TX
                LE 1M RX
                LE 2M TX
                LE 2M RX
                LE CODED TX
                LE CODED RX
      < HCI Command: LE Set Default PHY (0x08|0x0031) plen 3
              All PHYs preference: 0x00
              TX PHYs preference: 0x07
                LE 1M
                LE 2M
                LE Coded
              RX PHYs preference: 0x07
                LE 1M
                LE 2M
                LE Coded
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Default PHY (0x08|0x0031) ncmd 1
              Status: Success (0x00)
      @ MGMT Event: Command Complete (0x0001) plen 3
            Set PHY Configuration (0x0045) plen 0
              Status: Success (0x00)
      @ MGMT Event: PHY Configuration Changed (0x0026) plen 4
              Selected PHYs: 0x7fff
                BR 1M 1SLOT
                BR 1M 3SLOT
                BR 1M 5SLOT
                EDR 2M 1SLOT
                EDR 2M 3SLOT
                EDR 2M 5SLOT
                EDR 3M 1SLOT
                EDR 3M 3SLOT
                EDR 3M 5SLOT
                LE 1M TX
                LE 1M RX
                LE 2M TX
                LE 2M RX
                LE CODED TX
                LE CODED RX
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      0314f286
    • Jaganath Kanakkassery's avatar
      Bluetooth: Implement Get PHY Configuration mgmt command · 6244691f
      Jaganath Kanakkassery authored
      This commands basically retrieve the supported packet types of
      BREDR and supported PHYs of the controller.
      
      BR_1M_1SLOT, LE_1M_TX and LE_1M_RX would be supported by default.
      Other PHYs are supported based on the local features.
      
      Also this sets PHY_CONFIGURATION bit in supported settings.
      
      @ MGMT Command: Get PHY Configuration (0x0044) plen 0
      @ MGMT Event: Command Complete (0x0001) plen 15
            Get PHY Configuration (0x0044) plen 12
              Status: Success (0x00)
              Supported PHYs: 0x7fff
                BR 1M 1SLOT
                BR 1M 3SLOT
                BR 1M 5SLOT
                EDR 2M 1SLOT
                EDR 2M 3SLOT
                EDR 2M 5SLOT
                EDR 3M 1SLOT
                EDR 3M 3SLOT
                EDR 3M 5SLOT
                LE 1M TX
                LE 1M RX
                LE 2M TX
                LE 2M RX
                LE CODED TX
                LE CODED RX
              Configurable PHYs: 0x79fe
                BR 1M 3SLOT
                BR 1M 5SLOT
                EDR 2M 1SLOT
                EDR 2M 3SLOT
                EDR 2M 5SLOT
                EDR 3M 1SLOT
                EDR 3M 3SLOT
                EDR 3M 5SLOT
                LE 2M TX
                LE 2M RX
                LE CODED TX
                LE CODED RX
              Selected PHYs: 0x07ff
                BR 1M 1SLOT
                BR 1M 3SLOT
                BR 1M 5SLOT
                EDR 2M 1SLOT
                EDR 2M 3SLOT
                EDR 2M 5SLOT
                EDR 3M 1SLOT
                EDR 3M 3SLOT
                EDR 3M 5SLOT
                LE 1M TX
                LE 1M RX
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      6244691f
    • Jaganath Kanakkassery's avatar
      Bluetooth: Add defines for BREDR pkt_type and LE PHYs · 5075b972
      Jaganath Kanakkassery authored
      This also add macros for checking LMP support for different
      pkt_types
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      5075b972
    • Jaganath Kanakkassery's avatar
      Bluetooth: Define PHY flags in hdev and set 1M as default · 6decb5b4
      Jaganath Kanakkassery authored
      1M is mandatory to be supported by LE controllers and the same
      would be set in power on. This patch defines hdev flags for
      LE PHYs and set 1M to default.
      Signed-off-by: default avatarJaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      6decb5b4
  5. 23 Jul, 2018 1 commit