summaryrefslogtreecommitdiff
path: root/mesh
Commit message (Collapse)AuthorAgeFilesLines
...
* mesh/appkey: Fix memory leaksGopal Tiwari2022-05-311-2/+6
| | | | | | | | | | | | While performing the static analysis using the coverity tool found following memory leak reports bluez-5.64/mesh/appkey.c:143: leaked_storage: Variable "key" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): bluez-5.64/mesh/appkey.c:146: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
* mesh: use explicit uint32_t when bit shifting leftInga Stotland2022-03-313-11/+14
| | | | | | | | | This addresses a situation when a boolean type is represented by an integer and performing a left shift on a boolean causes an integer overflow. This fixes the following runtime error: "left shift of 1 by 31 places cannot be represented in type 'int'"
* mesh: Fix address overrun error in rx filterInga Stotland2022-03-262-16/+30
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following error for invalid read access when registering filter for incoming messages: 140632==ERROR: AddressSanitizer: stack-buffer-overflow on address... #0 0x7f60c185741d in MemcmpInterceptorCommon(... #1 0x7f60c1857af8 in __interceptor_memcmp (/lib64/libasan.so... #2 0x55a10101536e in find_by_filter mesh/mesh-io-unit.c:494 #3 0x55a1010d8c46 in l_queue_remove_if ell/queue.c:517 #4 0x55a101014ebd in recv_register mesh/mesh-io-unit.c:506 #5 0x55a10102946f in mesh_net_attach mesh/net.c:2885 #6 0x55a101086f64 in send_reply mesh/dbus.c:153 #7 0x55a101124c3d in handle_method_return ell/dbus.c:216 #8 0x55a10112c8ef in message_read_handler ell/dbus.c:276 #9 0x55a1010dae20 in io_callback ell/io.c:120 #10 0x55a1010dff7e in l_main_iterate ell/main.c:478 #11 0x55a1010e06e3 in l_main_run ell/main.c:525 #12 0x55a1010e06e3 in l_main_run ell/main.c:507 #13 0x55a1010e0bfc in l_main_run_with_signal ell/main.c:647 #14 0x55a10100316e in main mesh/main.c:292 #15 0x7f60c0c6855f in __libc_start_call_main (/lib64/libc.so.6+... #16 0x7f60c0c6860b in __libc_start_main_alias_1 (/lib64/libc.so.6+... #17 0x55a101003ce4 in _start (/home/istotlan/bluez/mesh/bluetooth-m...
* mesh: Skip unneeded logsMichał Lowas-Rzechonek2022-02-042-2/+2
|
* mesh: Make key_aid and net_key_id naming consistentMichał Lowas-Rzechonek2022-02-044-91/+67
| | | | | | | | - key_aid refers to application key AID - net_key_id refers to unique, internal id of the network key, used in net-keys.h Also, remove unused mesh_frnd_pkt struct.
* mesh: Fix sequence number of message in friend queueBrian Gix2022-02-041-1/+0
| | | | | | | As pointed out by https://github.com/bluez/bluez/issues/250, the last segment of a multi-segmented message added to Friend Queue was getting reset to the seqAuth value incorrectly. The correct sequence was set within the preceding for loop.
* mesh: Don't log error for false positive mkdir failureInga Stotland2021-12-063-5/+5
| | | | | When invoking mkdir() for mesh configuration storage, do not report an error if a target directory already exists.
* mesh: Fix unchecked return valueTedd Ho-Jeong An2021-10-184-15/+30
| | | | | This patch fixes the unchecked return value(CWE-252) issues reported by the Coverity.
* mesh: Implement ExportKeys() methodInga Stotland2021-09-273-1/+322
| | | | | | | | Add implementation for new method ExportKeys() on org.bluez.mesh.Management1 interface. This method is used by the authorized application to export information about network keys, application keys and device keys present in the local key database.
* mesh: Inclusive language changesArchie Pusaka2021-09-213-25/+25
| | | | | | | | According to https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf "flooding", "accept list", and "reject list" are the preferred terms. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* mesh: Fix race condition memory leakBrian Gix2021-05-191-0/+2
| | | | | | | This is a minor fix of a memory leak triggered on process exit if proceess has been killed right after requesting an outbound advertisement be sent. It is harmless, but will cause an occasional static analysis failure.
* mesh: Add single threading to prov-acp ob messagingBrian Gix2021-05-192-33/+56
| | | | | | | | Certain IOP and stress testing scenarios can cause additional outbound messages to be attempted before the prior outbound message completes. This patch adds queuing if outbpund messages are attempted too quickly so that the additional message is not sent until the prior message is ACKed.
* mesh: Normalize endian of public/private ECC keysBrian Gix2021-05-192-1/+10
| | | | | | | | | | The Mesh profile specification defines a Mesh byte order of Big Endian for Public keys used to calculate shared secrets. Further the specification sample data also show this same byte order for Private keys. However, our internal ECDH shared secret calculation requires Little Endian byte ordering. This fixes our DBus interface, and debugging output to use Mesh Byte Ordering (Big Endian) for all human readable input/output.
* mesh: Fix delivery of PB-ACK to acceptorsBrian Gix2021-05-191-1/+0
| | | | | Remove unneeded initialization that prevented the Acceptor roll of ever recognizing a valid PB-ACK.
* mesh: Add manpage for bluetooth-meshd daemonInga Stotland2021-05-191-0/+74
| | | | | This adds manpage with a brief description of BLuettoth Mesh daemon command line options.
* mesh: Fix memory leaksSteve Grubb2021-05-141-1/+3
| | | | The dir variable needs to be closed before leaving.
* mesh: Add missing "storage" option to help menuInga Stotland2021-05-131-1/+2
| | | | | This adds a previously missing entry for "storage" option when printing the daemon usage info.
* mesh: Fix net_key_confirm parameter declarationMarcel Holtmann2021-04-271-1/+1
|
* mesh: Fix network_id parameter declarationMarcel Holtmann2021-04-271-1/+1
|
* tools/mesh-cfgtest: Non-iteractive test for meshInga Stotland2021-04-101-1/+9
| | | | | | | This adds a non-interactive test to excercise different datapaths in bluetooth-meshd. The test cases utilize D-Bus based mesh APIs, e.g., to create a new network, import a node, import NetKey, import a remote node.
* mesh: Add unit test IOBrian Gix2021-04-105-17/+580
| | | | | | | | | | | | This adds a new type of mesh IO that is used for non-interactive testing. The new io option can be specified on command line as: --io unit:<socket_name> When the bluetooth-meshd daemon starts with the "unit" IO type, the daemon opens a socket (fd to open is provided after "unit:" in <socket_name>). The communication with the daemon is done either through the loop-back using mesh DBus-based APIs or the specified named socket.
* mesh: Add Provisioning Confirmation validity checkBrian Gix2021-04-092-2/+19
| | | | | Validate generated and received confirmation data is unique during provisioning.
* mesh: Fix segmented msg RX with friendshipBrian Gix2021-03-251-0/+1
| | | | | | This fixes an uninitialized memory issue where a message received for a local node is silently discarded if an uninitialized boolean is mistakenly set to TRUE, when friendships exist.
* mesh: Validate OTA provision security materialBrian Gix2021-03-092-0/+21
| | | | | When validating incoming security material, ensure that the data is unique to the provisioning session.
* mesh: Fix infinite loop on IVIndex updatePrzemysław Fierek2021-03-011-13/+21
| | | | | | | | | | | | | | | | | | | | This patch fixes inifinite loop problem caused by recurring call of the `net_key_beacon_refresh` function. Problem occurs when at least two nodes are connected to the same BlueZ instance and they are connected to the same network (use same network key). Issue is triggered when IVIndex update process stabilize and one of the nodes receives network beacon with IVUpdate flag set to 0. Then it processes the "local" beacon and compose new `snb` (with IVUpdate flag set to 0) attached to `net_key` instance. After that it calls `net_local_beacon` and another node processes the new beacon (this node has IVUpdate flag still set to 1). Note that the `net->ivupdate` has set value 1. The `update_iv_ivu_state` says that "IVU clear attempted too soon". The node composes new `snb` with IVUpdate flag set to 1 and writes it to the `net_key` instance in the `net_key_beacon_refresh` function. After that it calls `net_local_beacon` which causes repeat of all process. We are rotating in this loop until end-of-memory.
* mesh: Cleanup deprecated symbolic file permissionsBrian Gix2021-02-231-1/+1
|
* mesh: Combine common functions for NetKeys and AppKeysInga Stotland2021-02-181-70/+50
| | | | No change in functionality, code tightening.
* mesh: Add validation of Device UUID valueInga Stotland2021-02-161-9/+9
| | | | | Validate that the value of Device UUID supplied in CreateNetwork/Join/Import methods is compliant with RFC 4122.
* mesh: Clear node's agent pointer after agent removalInga Stotland2021-02-101-0/+1
| | | | | | When a node is created/provisioned/imported, the new node's agent is removed. The corresponding pointer in the node structure needs to be set to NULL to avoid pointing to freed memory.
* mesh: Update AppKeys on transition to Phase 0Michael N. Moran2021-01-044-2/+35
| | | | | | | | | | At the end of the mesh Key Refresh procedure when a subnet transitions to Phase 0, local AppKeys that were updated were not updating until the bluetooth-meshd daemon was restarted. This patch iterates the AppKeys at the end of mesh Key Refresh when the subnet transitions to Phase 0, setting the new state of each updated AppKey.
* mesh: Fix check for mkdir return value in keyring.cInga Stotland2020-12-041-6/+3
| | | | | | | | Remove check for mkdir() return value, since checking for zero does not cover "already exists" condition and adding extra check for errno value unnecessarily complicates the code. If mkdir() fails due to any reason than "already exists", the subsequent call to open() fails and the error is detected and corectly processed by the code.
* mesh: Zero out config node struct before initializingInga Stotland2020-12-041-0/+2
| | | | | | This memsets all the fields of mesh_db_node to zero prior to intializing some fields in mesh_config_node struct and creating a brand new node configuration. Just a precaution against having uninitialized items.
* mesh: Fix regression error in HB subscription setInga Stotland2020-11-191-5/+10
| | | | | | | | | | This fixes a regression introduced in commit c77bb848a9fb ("mesh: Refactor heartbeat pub/sub"): Heartbeat subscription should be enabled unless either source or destination are unassigned addresses or period log is zero. Also, decrement ref count on group destination address if period log is zero since the subscription is not supposed to be processed.
* mesh: Only deregister io for the last network detachedMichael N. Moran2020-11-101-2/+6
| | | | | | | | When multiple mesh networks are active and one is detached using Leave(), the I/O to all networks is halted. This patch prevents that by only deregistering the I/O if all networks have been detached.
* mesh/mesh-config-json: Fix errors found by static analysisInga Stotland2020-11-101-29/+33
| | | | | | This fixes miscellaneous issues related to unchecked return status and (temporary) allocated memory leaks due to daemon's exit on startup failure.
* mesh: Fix memory leak when failing to load a nodeInga Stotland2020-11-101-5/+2
| | | | | This fixes a memory leak that may occur on unsuccessful element initialization from storage.
* mesh: Fix memory leak and NULL pointer dereferenceInga Stotland2020-11-101-3/+5
| | | | | | | This fixes a potential NULL pointer dereferencing in mesh_model_pub_set() when virtual address publication cannot be successfully stored. Also, fix a minor memory leak that may occur on unsuccessful model initialization from storage.
* mesh: Fix errors found by static analysisInga Stotland2020-11-104-41/+58
| | | | | This fixes a NULL pointer dereference error (cfgmod-server.c) and miscellaneous issues related to unchecked return status.
* mesh: Re-arrange Join/Create/Import/Attach page savingBrian Gix2020-10-072-100/+104
| | | | | | | When an App is creating or attaching to a node, it first evaluates the validity of the Apps composition. Invalid compositions are not allowed to continue. Valid compositions need to be saved, which means that create_node_config() must be called as part of Composition validation.
* mesh: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-2148-481/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 48 License: LGPL-2.1-or-later mesh/mesh-mgmt.h mesh/mesh-mgmt.c mesh/net-keys.c mesh/mesh-io-api.h mesh/mesh.h mesh/net-keys.h mesh/model.h mesh/util.h mesh/appkey.c mesh/cfgmod.h mesh/appkey.h mesh/prov.h mesh/prov-acceptor.c mesh/net.c mesh/dbus.h mesh/friend.h mesh/mesh-io-generic.c mesh/main.c mesh/util.c mesh/dbus.c mesh/error.h mesh/mesh-config-json.c mesh/agent.h mesh/pb-adv.c mesh/crypto.c mesh/crypto.h mesh/friend.c mesh/pb-adv.h mesh/provision.h mesh/mesh-config.h mesh/mesh-io-generic.h mesh/agent.c mesh/cfgmod-server.c mesh/mesh-io.h mesh/keyring.h mesh/net.h mesh/keyring.c mesh/mesh-defs.h mesh/mesh.c mesh/rpl.c mesh/manager.c mesh/model.c mesh/mesh-io.c mesh/node.c mesh/prov-initiator.c mesh/rpl.h mesh/node.h mesh/manager.h
* mesh: Align option names with functionalityInga Stotland2020-09-031-7/+8
| | | | | | | | | Change option "config" ('c') to "storage" ('s) to specify a custom storage directory for node configuration. Change option 'f' (long name was missing) to "config" ('c') to specify a custom mesh configuration file to override the default mesh-main.conf
* mesh: Remove unused timing variable tx_startInga Stotland2020-09-031-6/+0
| | | | | In model.c, tx_Start is a static variable, dynamically set, but never used. Is removed now.
* mesh: Move RPL check from model to net layerInga Stotland2020-08-284-106/+106
| | | | | | | | | Check whether an incoming message has an RPL entry prior to handing it over to model layer for processing. If present in RPL or the RPL queue is full, ignore the incoming message. If the incoming message is processed successfully, add the message as a new RPL entry.
* mesh: Initialize RPL when creating or loading a nodeInga Stotland2020-08-285-21/+37
| | | | | | | | When either a new node is created or an existing node is loaded from storage, initialize RPL storage directory. Additionally, when an existing node configguration is read from storage, load saved RPL entries into the corresponding RPL lists.
* mesh: Store key indices as integers in node configInga Stotland2020-08-281-64/+38
| | | | | | Store NetKey and AppKey indices as integers instead of hex strings. This removes unnecessary string manipulations while not affecting the configuration file readability.
* mesh: Handle "options" dictionary in Send/Publish methodsInga Stotland2020-08-264-82/+75
| | | | | | | | | | | | | | | | | | | This adds processing of "options" dictionary argument in Send, DevKeySend & Publish methods on mesh.Node interface. This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword).
* mesh: Add random address to mesh HCI initDaan Pape2020-08-221-0/+9
| | | | This prevents error 0x12 when enabling/disabling LE scans
* mesh: Use valid net key index when handling Send callInga Stotland2020-08-222-6/+9
| | | | | | | Retrieve value of bound Net Key index based on the value of passed AppKey index. Check if the key is present and fail early in case of error. Also, pass the correct NetKey index to model layer in mesh_model_send(), instead of hard coded 0.
* mesh: Use correct retransmit parameters for publicationsInga Stotland2020-08-227-78/+104
| | | | | | This adds previously missing retransmit count and interval values specific to model publications. The values are configured by Config CLient and may be different to each model.
* mesh: Send correct NetKey index in DevKeyMessageReceivedInga Stotland2020-08-201-1/+2
| | | | | | The value of net_index in DevKeyMessageReceived() method must be set to the value of a subnet index on which a device key encoded message has been received. Was hard coded to 0. Fixed.