Commit Graph

6 Commits

Author SHA1 Message Date
Bastien Nocera cf57026838 Bluetooth: Fix a buffer overflow in mgmt_mesh_add()
JIRA: https://issues.redhat.com/browse/RHEL-2530

commit 2185e0fdbb2137f22a9dd9fcbf6481400d56299b
Author: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Date:   Mon Dec 12 05:08:28 2022 -0800

    Bluetooth: Fix a buffer overflow in mgmt_mesh_add()

    Smatch Warning:
    net/bluetooth/mgmt_util.c:375 mgmt_mesh_add() error: __memcpy()
    'mesh_tx->param' too small (48 vs 50)

    Analysis:

    'mesh_tx->param' is array of size 48. This is the destination.
    u8 param[sizeof(struct mgmt_cp_mesh_send) + 29]; // 19 + 29 = 48.

    But in the caller 'mesh_send' we reject only when len > 50.
    len > (MGMT_MESH_SEND_SIZE + 31) // 19 + 31 = 50.

    Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
    Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Signed-off-by: Bastien Nocera <bnocera@redhat.com>
2023-10-23 09:05:28 +02:00
Bastien Nocera 75701020c7 Bluetooth: Implement support for Mesh
JIRA: https://issues.redhat.com/browse/RHEL-2530

commit b338d91703fae6f6afd67f3f75caa3b8f36ddef3
Author: Brian Gix <brian.gix@intel.com>
Date:   Thu Sep 1 12:19:13 2022 -0700

    Bluetooth: Implement support for Mesh

    The patch adds state bits, storage and HCI command chains for sending
    and receiving Bluetooth Mesh advertising packets, and delivery to
    requesting user space processes. It specifically creates 4 new MGMT
    commands and 2 new MGMT events:

    MGMT_OP_SET_MESH_RECEIVER - Sets passive scan parameters and a list of
    AD Types which will trigger Mesh Packet Received events

    MGMT_OP_MESH_READ_FEATURES - Returns information on how many outbound
    Mesh packets can be simultaneously queued, and what the currently queued
    handles are.

    MGMT_OP_MESH_SEND - Command to queue a specific outbound Mesh packet,
    with the number of times it should be sent, and the BD Addr to use.
    Discrete advertisments are added to the ADV Instance list.

    MGMT_OP_MESH_SEND_CANCEL - Command to cancel a prior outbound message
    request.

    MGMT_EV_MESH_DEVICE_FOUND - Event to deliver entire received Mesh
    Advertisement packet, along with timing information.

    MGMT_EV_MESH_PACKET_CMPLT - Event to indicate that an outbound packet is
    no longer queued for delivery.

    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Signed-off-by: Bastien Nocera <bnocera@redhat.com>
2023-10-23 09:05:17 +02:00
Gopal Tiwari 38140d7e08 Bluetooth: mgmt: Introduce mgmt_alloc_skb and mgmt_send_event_skb
Bugzilla: http://bugzilla.redhat.com/2066188

commit 8aca46f91c42020bc58cd56e464a1101e517aa10
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Fri Dec 3 16:15:40 2021 -0800

    Bluetooth: mgmt: Introduce mgmt_alloc_skb and mgmt_send_event_skb

    This introduces mgmt_alloc_skb and mgmt_send_event_skb which are
    convenient when building MGMT events that have variable length as the
    likes of skb_put_data can be used to insert portion directly on the skb
    instead of having to first build an intermediate buffer just to be
    copied over the skb.

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:05 +05:30
Gopal Tiwari c191da71ad Bluetooth: hci_sync: Convert MGMT_OP_READ_LOCAL_OOB_DATA
Bugzilla: http://bugzilla.redhat.com/2066188

commit f892244b05bf6a99e48db14f8bbd96db16bcfa69
Author: Brian Gix <brian.gix@intel.com>
Date:   Wed Oct 27 16:58:52 2021 -0700

    Bluetooth: hci_sync: Convert MGMT_OP_READ_LOCAL_OOB_DATA

    New functions:
      hci_read_local_oob_data_sync

    This function requires all of the data from the cmd cmplt event
    to be passed up to the caller via the skb.

    mgmt-tester paths:
    Read Local OOB Data - Not powered
    Read Local OOB Data - Legacy pairing
    Read Local OOB Data - Success SSP
    Read Local OOB Data - Success SC

    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:01 +05:30
Gopal Tiwari 8b5661c87d Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 1
Bugzilla: http://bugzilla.redhat.com/2066188

commit 161510ccf91c961638940b03abb1ee804be53a97
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:39 2021 -0700

    Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 1

    This make use of hci_cmd_sync_queue for the following MGMT commands:

    Set Device Class
    Set Device ID
    Add UUID
    Remove UUID

    tools/mgmt-tester -s "Set Device Class"

    Test Summary
    ------------
    Set Device Class - Success 1                         Passed
    Set Device Class - Success 2                         Passed
    Set Device Class - Invalid parameters 1              Passed
    Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0599 seconds

    tools/mgmt-tester -s "Set Device ID"

    Test Summary
    ------------
    Set Device ID - Success 1                            Passed
    Set Device ID - Success 2                            Passed
    Set Device ID - Disable                              Passed
    Set Device ID - Power off and Power on               Passed
    Set Device ID - SSP off and Power on                 Passed
    Set Device ID - Invalid Parameter                    Passed
    Total: 6, Passed: 6 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.107 seconds

    tools/mgmt-tester -s "Add UUID"

    Test Summary
    ------------
    Add UUID - UUID-16 1                                 Passed
    Add UUID - UUID-16 multiple 1                        Passed
    Add UUID - UUID-16 partial 1                         Passed
    Add UUID - UUID-32 1                                 Passed
    Add UUID - UUID-32 multiple 1                        Passed
    Add UUID - UUID-32 partial 1                         Passed
    Add UUID - UUID-128 1                                Passed
    Add UUID - UUID-128 multiple 1                       Passed
    Add UUID - UUID-128 partial 1                        Passed
    Add UUID - UUID mix                                  Passed
    Total: 10, Passed: 10 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.198 seconds

    tools/mgmt-tester -s "Remove UUID"

    Test Summary
    ------------
    Remove UUID - Success 1                              Passed
    Remove UUID - All UUID - Success 2                   Passed
    Remove UUID - Power Off - Success 3                  Passed
    Remove UUID - Power Off and On - Success 4           Passed
    Remove UUID - Not Exist - Invalid Params 1           Passed
    Total: 5, Passed: 5 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0908 seconds

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Johan Hedberg a380b6cff1 Bluetooth: Add generic mgmt helper API
There are several mgmt protocol features that will be needed by more
than just the current HCI_CHANNEL_CONTROL. These include sending generic
events as well as handling pending commands. This patch moves these
functions out from mgmt.c to a new mgmt_util.c file.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-03-17 18:03:08 +01:00