Commit graph

21541 commits

Author SHA1 Message Date
Benjamin Bigler
06a725c1c8 net: mgmt: prevent event_work_handler from blocking
Fix system workqueue block caused by mgmt_event_work_handler
when CONFIG_NET_MGMT_EVENT_SYSTEM_WORKQUEUE is enabled.

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-07-09 11:49:47 +02:00
Adrien Ricciardi
8ca14a7762 fs: nvs: Add more strict checks to determine if an ATE is valid
Make sure that the ATE metadata does not overflow the sector size.
Take into account the data length and also the mandatory reserved ATEs
in each sector.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2024-07-08 12:15:42 -04:00
Emil Gydesen
5901dcbaa7 Bluetooth: Kconfig: Increase BT_HCI_TX_STACK_SIZE for ISO_BROADCAST
When using an encrypted broadcast, the previous value is no
longer enough and caused a stack overflow.

Slightly increased the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-08 16:03:21 +02:00
Pieter De Gendt
0e9a6ee802 net: buf: Add const to net_buf API
Some public API functions do not modify the net_buf instances and can
declare these arguments as const.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-08 16:02:39 +02:00
Emil Gydesen
c46b2e086b Bluetooth: Kconfig: Add dependency on BT_CONN for PAST
PAST only works if you have a connection, so the PAST
feature should depend on that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-08 09:27:11 +02:00
Emil Gydesen
711b42ae16 Bluetooth: Host: Fix recv_enabled field for PAST
When syncing to a PA using PAST then the sync_info.recv_enabled
was always just set to true, regardless of what mode was set
during the subscribe parameters.

The mode(s) are now stored in an array (with the default value
as well) so that we can retrieve that information when the PA
has synced via PAST.

It was considered to put the `mode` value into the `bt_conn`
struct, but that would require an API change as the `bt_conn`
parameter for the subcribe function uses `const`.

This commit also modifies the guard for PAST to be the more
correct value CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER instead
of just CONFIG_BT_CONN.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-08 09:27:11 +02:00
Emil Gydesen
03d07950aa Bluetooth: OTS: Fix issue with callbacks not being set
The checks for callbacks in bt_ots_init did not correctly take the
ots_init->features.oacp into account for all callbacks, which
caused some issues.

Slightly optimized the check for ots->cb->obj_read by moving the check
and reducing the number of places the code calls oacp_read_proc_cb.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-06 17:02:23 +02:00
Jonathan Rico
be61ae4c9c Bluetooth: host: disallow scan with timeout when BT_PRIVACY=y
See comment in code.

Fixes #73634

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-05 18:43:40 +02:00
TOKITA Hiroshi
40629ac9f9 fb: cfb: Fix CID 394240
This is a simple deletion of unnecessary processing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-07-05 18:39:22 +02:00
Jonathan Rico
a7c5fb7065 Bluetooth: GATT: factor out notify callback
- De-duplicate code
- Add `LOG_WRN` on unsubscribe error

Fixes #74720
Fixes #74721

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-05 18:38:17 +02:00
Lyle Zhu
c9708ff951 Bluetooth: A2DP: Check the pointer before using
Check the pointer `sep` before using it.

Fixes #74734.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-07-05 12:33:38 +02:00
Lyle Zhu
8276d4f79a Bluetooth: A2DP: Fix NULL pointer references issue
The opposite logic is used to determine if a
pointer is valid.

Correct the judgment logic.

Fixes #74728.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-07-05 12:32:41 +02:00
Lyle Zhu
6fad658569 Bluetooth: A2DP: Fix NULL pointer references issue
The opposite logic is used to determine if a
pointer is valid.

Correct the judgment logic.

Fixes #74732.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-07-05 12:32:05 +02:00
Robert Lubos
4625fa713f net: mqtt: Fix possible socket leak with websocket transport
In case underlying TCP/TLS connection is already down, the
websocket_disconnect() call is expected to fail, as it involves
communication. Therefore, mqtt_client_websocket_disconnect() should not
quit early in such cases, as it could lead to an underlying socket leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-05 12:29:33 +02:00
Lyle Zhu
9be685eefe Bluetooth: A2DP: Access pointer if it is valid
Only access if the pointer `stream` is valid.

Fixes #74735
Fixes #74740

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-07-05 12:28:45 +02:00
Emil Gydesen
19fe0673f9 Bluetooth: ISO: Tone down some dbg logs
Several log statements were using the regualar LOG_DBG,
but when ISO is actually used, those were called every TX
which at 10ms SDU intervals would fill up the log really fast
and not provided much value outside of some specific debugging.

Modified those logs to use BT_ISO_DATA_DBG which is another
log level for ISO data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-05 12:28:01 +02:00
Jonathan Rico
ac37d6483a Bluetooth: Host: Remove conn param update checks
The rationale behind that change is that the Application can use the
`bt_conn_le_param_update()` API to signal the controller to reschedule
the link.

Even if the new connection params are within the old ones, the
controller would be free to choose an e.g. smaller interval. The host
API should not prevent this usage.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/74292

Co-authored-by: Knut Eldhuset <knut.eldhuset@nordicsemi.no>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-04 18:00:35 -04:00
Nicolas Pitre
0c1301e728 demand_paging: LRU eviction: remove restriction on PF index 0
The first page frame index was reserved for head and tail ^pointers.
However there are cases where the first frame is actually made
evictable and would trigger the assertion guarding against that.

Fix this by applying an offset to actual frame indexes.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-07-03 15:07:03 -04:00
Alberto Escolar Piedras
1df86af309 Revert "net: sockets: move poll implementation to zvfs"
This reverts commit 93973e2ead.

PR #73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.

For more details on the issue see
https://github.com/zephyrproject-rtos/zephyr/issues/75205

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-07-03 15:03:05 -04:00
Alberto Escolar Piedras
14e4de6415 Revert "net: sockets: move select() implementation to zvfs"
This reverts commit 49ac1912b2.

PR #73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.

For more details on the issue see
https://github.com/zephyrproject-rtos/zephyr/issues/75205

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-07-03 15:03:05 -04:00
Emil Gydesen
b413b505ee Bluetooth: BAP: Broadcast: Fix state checks
The existing state checks for both the broadcast sink
and broadcast source only ever checked the first BIS.
This sort of made sense, since they are all linked by HCI
(i.e. they share the same state), but there is a race condition
in the ISO and BAP callbacks that could allow applications
to delete sinks and sources before all the ISO callbacks
had been handled.

By treating the sink and source states as the highest value
of the BIS, then we better treat all BIS the same.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-03 15:28:17 +02:00
Jukka Rissanen
c77b818679 net: ipv6-pe: Verify that hmac calculation was ok
Make sure to check return values of mbedtls hmac APIs so that
the digest is calculated properly.

Fixes #75259
Fixes #75260
Fixes #75261

Coverity-CID: 366271
Coverity-CID: 366277
Coverify-CID: 366279

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-07-03 15:25:58 +02:00
Jonathan Rico
85c57c2da3 Bluetooth: host: ensure ownership of conn on TX path
This is a bug-fix:

When upper layers want to send something, they add a `conn` object to a
list. They do so by adding a node on `struct conn` rather than the object
itself.

We forgot to increase the reference count of the connection object when
doing so. This means that there can be a scenario where the conn object is
destroyed and re-used while still being on the TX list/queue.

This is bad for obvious reasons.

This patch fixes that by:
- increasing the refcount when putting on the TX list
- decreasing the refcount *only* when popping off the TX list
- passing a new reference from `get_conn_ready` into `bt_conn_tx_processor`

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-02 14:18:23 +02:00
Jukka Rissanen
9647db8808 net: dns: Avoid superfluous error message
If we have configured the DNS dispatcher to be only as a
responder but receive a query response, or if we are only
as a resolver but receive a query, then the dispatcher just
ignores the packet and returns -ENOENT.

Unfortunately we print an error message in this case

[00:10:18.818,000] <err> net_dns_dispatcher: DNS recv error (-2)

which is totally unnecessary and causes confusion so do not
print an error message in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-07-02 14:11:15 +02:00
Emil Gydesen
fa447948d2 Bluetooth: BAP: Scan del: Overwrite metadata if len == 0
If the metadata length is 0 in the mod source operation,
we set the length to 0 and memset the stored value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-01 18:14:14 +02:00
Benjamin Cabé
1f0c22eb01 net: ptp: fix incorrect req_timestamp decoding
Removed incorrect use of ntoh to decode Delay_Req timestamp

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-07-01 18:13:42 +02:00
Benjamin Cabé
a89a5ee52d net: ptp: fix offset check by adding missing int64_t cast
Add cast to NSEC_PER_SEC macro to correctly check offset.
Prior to this commit, the would eval to true incorrectly.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-07-01 18:13:42 +02:00
Flavio Ceolin
bb56c3898c bluetooth: host/classic: Fix possible buffer overflow
Fix possible buffer overflow in rfcomm. Check the buffer len
before read it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-07-01 09:13:22 +02:00
Jukka Rissanen
0cfd963ddc net: wifi: shell: Avoid using sscanf
The sscanf() is not available for minimal libc so it cannot be used.
Use the net_bytes_from_str() that is provided for this purposes.

Fixes #75029

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-28 20:58:50 -04:00
Chaitanya Tata
fbe7e95359 net: sockets_service: Fix thread failure
In case of thread failure, fix the registrations by properly managing
the synchronization i.e. use conditional wait only if thread is being
initialized or will be initialized, else check for success or failure
without waiting for conditional variables.

Fixes #73523.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-06-28 21:52:49 +02:00
Daniel Leung
cb0a3ce6aa logging: dictionary: keep string section if always runtime
If logging packages need to be created at runtime, the format
strings need to be in memory for the packaging code to know
what to be packed. So prevent stripping the logging string
section if CONFIG_LOG_ALWAYS_RUNTIME is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-28 21:14:14 +02:00
Flavio Ceolin
e1f20f36a0 pm: policy: Move device power state constraints to policy
Move information about device power state constraints from device
to policy.

It slows down the constraints lookup since we now have to find the
constraints for a device in a global array, but it saves resources
because we don't need to add a reference to constraints in all devices
instances.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-28 12:22:28 -04:00
Francois Ramu
9e03abb8cb debug: no UNALIGNED_ACCESS_SUPPORTED for cortex M0 or M0plus
Set the UNALIGNED_ACCESS_SUPPORTED only for MCU with cortex M
that are neither M0 nor M0plus
Cortex M0 or M0plus mcus do not support un-aligned address access

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-28 12:21:18 -04:00
Emil Gydesen
1159c2adda Bluetooth: OTS: Add return validation of bt_uuid_create for client
The OTS client did not validate the return value of bt_uuid_create.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-28 07:50:30 -04:00
TOKITA Hiroshi
83860c2dfd fb: cfb: Add framebuffer deinitialize function
Add the `cfb_framebuffer_deinit` function for deinitializing
the framebuffer.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-06-28 07:21:47 -04:00
TOKITA Hiroshi
d542e75975 fb: cfb: Fix CFB_FONT_MSB_FIRST font rendering
I broke the rendering of the CFB_FONT_MSB_FIRST font in
the previously committed #53796.
I will correct the entire font rendering process to make it
easier to remove the restriction that the vertical size of
the font must be a multiple of 8.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-06-28 07:21:47 -04:00
Emil Gydesen
7b0784c1f6 Bluetooth: ASCS: Validate num_ases in CP requests
Add validation of the number of ASEs in control point
write requests.

This validates that the number of ASEs
in the control point is not greater than the total number
of ASEs we support.

This also validates that the GATT MTU is large enough to
hold all the responses from the write since those can only be
sent as notifications and never be truncated.

Finally this validates and updates the size of the buffer used to
hold the responses, which may be an optimization for some builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-28 07:20:47 -04:00
Jordan Yates
91f8c1aea9 everywhere: replace #if IS_ENABLED() as per docs
Replace `#if IS_ENABLED()` with `#if defined()` as recommended by the
documentation of `IS_ENABLED`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-28 07:20:32 -04:00
Pisit Sawangvonganan
cfbe2adabc net: if: remove unused eth_ctx variable
Removed the declaration and assignment of `eth_ctx` variable from
`net_if_get_wifi_sta` and `net_if_get_wifi_sap` functions since
it was not being used.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-28 11:37:25 +02:00
Robert Lubos
5442e47dfa net: tcp: Delay ACK if no PSH flag is present
Delay an ACK in case no PSH flag is present in the data packet. as
described in RFC 813. This allows to reduce the number of ACK packets
we send and thus improve the TCP download throughput.

The results achieved on `nucleo_h723zg` board and the zperf sample
are as follows:
Before: 77.14 Mbps
After: 93.14 Mbps

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-28 11:34:50 +02:00
Jordan Yates
cf870e8350 bluetooth: correct bt_le_scan_param scan type
The `type` parameter of `struct bt_le_scan_param` is documented as
taking a `BT_LE_SCAN_TYPE_*` value, not a `BT_HCI_LE_SCAN_*` value.

In practice this makes no difference as the values are defined as the
same integer, but does result in `<zephyr/bluetooth/hci.h>` not needing
to be included.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-28 11:34:36 +02:00
Benedikt Schmidt
bc4743fbf2 logging: avoid overflow of package length in log_msg
Check if the calculated package length exceeds the maximum possible
value.
Fixes #75015

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-06-28 11:34:25 +02:00
Chris Friedt
49ac1912b2 net: sockets: move select() implementation to zvfs
Move the implementation of zsock_select() to zvfs_select(). This
allows other types of file descriptors to also make use of
select() functionality even when the network subsystem is not
enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-27 09:01:23 -04:00
Chris Friedt
93973e2ead net: sockets: move poll implementation to zvfs
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-27 09:01:23 -04:00
Emil Gydesen
044f8aaeb3 Bluetooth: OTS: Add len validation in olcp_ind_handler
Verify the length of the indication before we pull from the
buffer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-27 08:49:20 -04:00
Adam Wojasinski
3b78e76554 net: lib: ptp: Fix issues raised by static analyzer
Fix minor issues reported by static analysis tool.

Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
2024-06-27 08:48:59 -04:00
Babak Arisian
0c611d01a7 Bluetooth: Audio: Dereference null return value in cap_initiator.c
Null pointer dereferences in functions:
  bt_cap_initiator_unicast_audio_update (Line 1478)
  bt_cap_initiator_unicast_audio_stop (Line 1693)

Fixes #74729 and #74739

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-06-27 08:48:46 -04:00
Babak Arisian
a895abab86 Bluetooth: Audio: Unchecked return value in audio.h
Unchecked return value in functions: print_ltv_array (Line 287)

Fixes #74733

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-06-27 08:48:18 -04:00
Adrien Ricciardi
08496ff6b4 fs: nvs: Improve nvs_calc_free_space() result precision
The nvs_calc_free_space() function does not return 0 when the NVS
is considered full, because some special ATEs are not taken into account.

This commit takes into account the ATE that is reserved for deletion in
each sector, in addition of the 'GC done' ATE when present.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2024-06-27 10:53:28 +02:00
Lyle Zhu
1d1dc7a875 Bluetooth: Classic: HF_AG: Fix unexpected return
When `buf->len` is 0, the function of the while-loop
will be returned with error code `-ENOTSUP`.
The code block after while-loop cannot be reached
event though it is a correct command.

Use `buf->len` as the end condition of the while-loop.

Fixes #74730.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-06-27 10:53:17 +02:00