Commit graph

22,555 commits

Author SHA1 Message Date
Luca Burelli
2e085ba29a llext: harmonize error codes
This patch changes the error codes returned by the ELF subsystem to be
more consistent with the standard error descriptions. In particular:

- issues with the ELF file are now reported as -ENOEXEC;
- valid but unsupported edge cases are reported as -ENOTSUP;
- failures in searching for an entry are reported as -ENOENT.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 19:04:06 +02:00
Luca Burelli
9450240419 llext: fix table count check
llext_load() included a check to ensure that the ELF file contains all
the necessary tables, but it was not functional. Add the missing check
and rename the variable to avoid confusion with the total section count.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 19:04:06 +02:00
Pisit Sawangvonganan
9b2ab20f23 bluetooth: fix typo in (include/zephyr/bluetooth, subsys/bluetooth/)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `include/zephyr/bluetooth` and `subsys/bluetooth`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-09 17:20:38 +02:00
Robert Lubos
e5d67adf80 net: sockets: services: Don't modify pollfd array from other threads
pollfd array used with zsock_poll() should not be modified while inside
zsock_poll() function as this could lead to unexpected results. For
instance, k_poll already monitoring some kernel primitive could report
an event, but it will not be processed if the monitored socket file
descriptor in the pollfd array was set to -1. In result,
zsock_poll() may unexpectedly quit prematurely, returning 0 events, even
if it was requested to wait infinitely.

The pollfd arrays used by zsock_poll() (ctx.events) is reinitialized
when the service thread is restarted so modifying it directly when
registering/unregistering service is not really needed. It's enough if
those functions notify the eventfd socket used to restart the services
thread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 17:19:12 +02:00
Andrey Dodonov
a4123a8ea2 net: lib: websocket: call socket poll for websocket
If we couldn't send all (or any data) via the socket,
invoke poll instead of blindly retrying and flooding the socket

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2024-07-09 14:04:29 +02:00
Andrey Dodonov
15ead53ad9 net: lib: http: call socket poll for http_client send
If we couldn't send all (or any data) via the socket,
invoke poll instead of blindly retrying and flooding the socket.
Respect timeout through http_client_req

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2024-07-09 14:04:29 +02:00
Pieter De Gendt
9d8881816e zbus: Use section iterator for observations
Iterating the observations can be simplified to a struct iterator instead
of first getting the count and looping afterwards.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-09 14:03:33 +02:00
Pieter De Gendt
990c5e13cb zbus: Static channel data initialization
Init the channel data semaphore and observer list statically.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-09 14:03:33 +02:00
Zihao Gao
6ebb65d163 Bluetooth: fix compiling issue when either A2DP SRC or SNK are not enabled
Some of the A2DP interfaces are not defined if the corresponding feature
is not enabled, and therefore shall not be initialized.
This patchs include the interfaces/variables by the configurations to
go through the compiling stage.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-07-09 14:03:07 +02:00
Krzysztof Chruściński
347eeababf logging: Fix runtime filtering when frontend and userspace is used
When userspace is used and frontend was used for logging then runtime
filtering was failing because in user context filtering data was
accessed and filtering data is in the kernel space. Fixing that and
adding runtime filtering to the pre frontend function which is
already executed in the kernel space and filter data can be
accessed.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Krzysztof Chruściński
8ed29a625a logging: Fix UART dictionary frontend configuration
Logging string stripping depends on LOG_DICTIONARY_SUPPORT being
enabled and it was not set in UART dictionary frontend.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Krzysztof Chruściński
9876075de1 logging: Allow runtime filtering for frontend only case
Log frontend supports runtime filtering so it should be
allowed to enable it even when only frontend is used with
no backends.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Luca Burelli
5ce6a750a5 llext: add explicit cast to fix Coverity CID: 392507
From https://mails.dpdk.org/archives/dev/2021-December/231212.html:

    Downcasting a void* to struct aesni_gcm_session* caused the session
    data to be treated as tainted. Removing the void* temporary variable
    and adding a cast avoids this issue.

Try the same approach here to prevent the ldr->sect_hdrs pointer from
being treated as tainted.

May fix #74817.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 11:51:29 +02:00
Benjamin Bigler
1db356e35c net: mgmt: Fix build error when event direct enabled without event info
If CONFIG_NET_MGMT_EVENT_DIRECT is enabled and CONFIG_NET_MGMT_EVENT_INFO
disabled it does not build because mgmt_push_event writes to non existing
struct members

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-07-09 11:49:47 +02:00
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