Commit graph zephyr/subsys
Author SHA1 Message Date
Valerio Setti
5aa4bd6bbd random: enable Xoshiro post-processing when ENTROPY_NEEDS_POST_PROCESSING
Enabling CONFIG_XOSHIRO_RANDOM_GENERATOR when
CONFIG_ENTROPY_NEEDS_POST_PROCESSING is set, we can support entropy
drivers which are not able to provide large amount of data.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-03-31 13:50:34 -05:00
Sebastiaan Merckx
03bff638ac net: dns: dns_sd: fix incorrect use of buffer size
The functions that add DNS records (PTR, SRV, TXT, AAAA, A) all use a
buf_size argument which represents the size of the whole buffer, not the
remaining size. The higher function that calls these did not provide the
correct argument: it passed the remaining size in the buffer.

Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
2026-03-31 10:36:36 -05:00
alperen sener
6d137ae015 bluetooth: host: defer IRK resolving list update to scan/adv start
Stop scheduling bt_id_add() as workqueue work during settings load.
Mark keys BT_KEYS_ID_PENDING_ADD only, then flush them synchronously
in start_scan(), adv_start_legacy()/bt_le_ext_adv_start(),
bt_conn_le_create and bt_conn_le_create_auto when
BT_DEV_ID_PENDING is set.

We don't necessarily need to update resolving list in controller
unless actively start using it, also eliminates a race where a
workqueue-issued bt_id_add() blocks on HCI while bt_keys_clear()
concurrently zeroes the same key slot.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2026-03-31 10:34:08 -05:00
Ofir Shemesh
218aa7e19f net: dhcpv6: log received address at info level
The DHCPv4 client logs the received address with NET_INFO when an
address is successfully obtained from the server. The DHCPv6 client
had no equivalent log message, making it difficult to confirm that
DHCPv6 address assignment succeeded.

Add a NET_INFO log when a DHCPv6 address is successfully configured,
consistent with the DHCPv4 client behavior.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 15:06:15 -05:00
Ofir Shemesh
4398087c3e net: config: fix IPv6 event callback not registered for DHCPv6-only setups
In setup_ipv6(), the net management event callback registration was
placed after the early exit for empty CONFIG_NET_CONFIG_MY_IPV6_ADDR.
This means that in DHCPv6-only configurations (no static IPv6 address),
the callback was never registered, and the IPv6 address and lifetime
were never printed when DHCPv6 obtained an address.

This is inconsistent with setup_ipv4(), which correctly registers the
callback before the empty address check, allowing DHCPv4 address
events to be handled even without a static IPv4 address.

Move the event callback registration and router flag check before the
empty address goto, and always include NET_EVENT_IPV6_ADDR_ADD in the
event mask so that DHCPv6 address additions are always captured.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 15:06:15 -05:00
Ofir Shemesh
9ed81aacb5 net: context: set sa_family before ephemeral port allocation
In net_context_get(), contexts[i].local is memset to zero before
find_available_port() is called. This leaves sa_family as 0, which
causes check_used_port() to skip both the IPv6 (sa_family ==
NET_AF_INET6) and IPv4 (sa_family == NET_AF_INET) collision-detection
branches, unconditionally returning "port available".

When the PRNG produces the same random port for two consecutive
socket() calls, the collision is not detected and both contexts are
assigned the same ephemeral port. The duplicate is only caught later
during listen() → net_conn_register(), which finds the identical
connection handler and returns -EADDRINUSE (errno 112).

Fix by setting sin6_family / sin_family on the local address
immediately after the memset and before find_available_port() is
called, so that check_used_port() enters the correct address-family
branch and properly detects port collisions.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 10:10:59 -05:00
Nikhil Namjoshi
83d4a298f0 net: ipv6: Fix extention length header validation
The exthdr_len was previously validated against the total
packet length, which did not account for the header's offset.
This could allow a crafted packet to cause an out-of-bounds
read by claiming a length that exceeds the remaining buffer.

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

This commit:
1. Validates exthdr_len against (pkt_len - start_offset).
2. Adds strict bounds checking for sub-options (PADN/others)
   to ensure they do not exceed the extension header boundary.
3. Validates the return value of net_pkt_skip().

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-03-30 10:08:20 -05:00
Nicholas Cadieux
2665774487 usb: usb_c: pe: fix DPM notifications on PD attach and detach
On PD capable SRC detach, DPM was not being notified of
POWER_CHANGE_0A0 or NOT_PD_CONNECTED. Fix by notifying
POWER_CHANGE_0A0 in tc_attached_snk_exit() and NOT_PD_CONNECTED in
pe_suspend_entry().

On PD capable SNK or SRC detach, pe_suspend_entry() did not clear
the explicit contract flag. Fix by clearing PE_FLAGS_EXPLICIT_CONTRACT
in pe_suspend_entry().

On PD capable SNK attach, DPM was not being notified of PD_CONNECTED
at the correct time. Fix by notifying PD_CONNECTED when PS_RDY is
successfully transmitted (source) or received (sink), using
atomic_test_and_set_bit() to prevent duplicate notifications during
renegotiations.

Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
2026-03-30 10:02:58 -05:00
Anas Nashif
61c42025fc Revert "modules: mbedtls: avoid infinite psa_generate_random() recursion"
This reverts commit 918c5b98f4.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-03-28 08:03:34 -04:00
Oleh Konko
09ad7174e9 bluetooth: l2cap: validate alloc_buf user data
validate the assumptions about buffers returned by alloc_buf() in the
LE CoC receive path.

if the returned buffer does not provide enough user_data space for the
internal segment counter, disconnect and drop the buffer instead of
reading or writing past the metadata area.

also document that alloc_buf() must return a buffer with at least
sizeof(uint16_t) bytes of user_data.

Signed-off-by: Oleh Konko <security@1seal.org>
2026-03-27 20:22:31 -04:00
Tomi Fontanilles
918c5b98f4 modules: mbedtls: avoid infinite psa_generate_random() recursion
By making `MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` depend on that neither
`CTR_DRBG_CSPRNG_GENERATOR` nor `PSA_CSPRNG_GENERATOR` is enabled so if
they are we automatically fall back to `MBEDTLS_PSA_CRYPTO_LEGACY_RNG`.

This combination is problematic because we get in a scenario where
`psa_generate_random()` => `get_random_data()` => `sys_csrand_get()` =>
`psa_generate_random()`.

Resolves #105626.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-27 20:21:00 -04:00
Hieu Vo
b0ed2b5209 crc: Add dependency for CRC_HW_HANDLER
Make CRC_HW_HANDLER depend on necessary DTS node being presented.

Signed-off-by: Hieu Vo <hieu.vo@nordicsemi.no>
2026-03-27 14:00:57 -05:00
Jun Lai
40f01a3111 logging: mtrace: fix log overwrite issue
Add an internal cache buffer in Intel's
adsp mtrace backend to mitigate log overwrite
issue when slot window is full.

Signed-off-by: Jun Lai <jun.lai@dolby.com>
2026-03-27 12:35:27 -04:00
Fabio Baltieri
4d8eeff467 usb: device_next: cdc_acm: fix an llvm warning
Fixes an unused function warning when compiling with llvm, looks like
that does not fire with gcc for inline functions but it does for llvm,
tested with:

west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/cdc_acm --
-DTOOLCHAIN_VARIANT_COMPILER=llvm -DCONFIG_UART_LINE_CTRL=n

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-03-27 12:35:07 -04:00
Fabio Baltieri
f08d56de23 usb: device_next: hid: fix some llvm warnings
Fixes:

zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:635:19:
warning: unused function 'hid_dev_set_out_polling' [-Wunused-function]
zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:665:19:
warning: unused function 'hid_dev_set_in_polling' [-Wunused-function]

When compiling with LLVM:

west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/hid-keyboard --
-DTOOLCHAIN_VARIANT_COMPILER=llvm

Functions are only used when CONFIG_USBD_HID_SET_POLLING_PERIOD is
enabled, set as __maybe_unused instaed of inline.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-03-27 12:35:07 -04:00
Aleksandr Khromykh
6c80ebb51b bluetooth: mesh: increase settings workq stack
Commit increases mesh settings workq stack size.
Thread analyze shows 100% consumption.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-03-27 08:18:08 -04:00
Raffael Rostagno
8047d8f408 pm: device: Suppress error message when device is busy
Power managed devices should be able to return -EBUSY at
pm_action() (driver) calls without generating error log messages.
Suppress such error messages to allow the driver to decide at
sleep time if it still is unable to suspend, without generating
log noise.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2026-03-26 14:02:36 -04:00
Josuah Demangeon
7f1bf6028c usb: uvc: fix incorrect frame interval decoding
UVC counts frame intervals as 100ns units, so to get a number in
nanosecond, the value from USB needs to be divided by either
(USEC_PER_SEC * 10) or (NSEC_PER_SEC / 100). A mix of the two
was used.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-03-26 10:47:08 -04:00
Johann Fischer
04c150e3df usb: uvc: assign the actual streaming interface number
When UVC is part of a multi-function device, baInterfaceNr(0) may point
to an incorrect interface number. Assign the actual streaming interface
number after the configuration descriptor is initialized.

This is follow-up on commit 8d7bb597fc
("usb: uvc: use uvc_device_ in API and add _enable()/_shutdown()").

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-03-26 10:45:17 -04:00
Tomi Fontanilles
7109043090 modules: mbedtls: stop including Mbed TLS configuration header file
Standard Mbed TLS header files already take care of doing it properly.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-26 07:19:32 -04:00
Tomi Fontanilles
c6e6f3e638 modules: mbedtls: rename CONFIG_(MBEDTLS|TF_PSA_CRYPTO)_CFG_FILE
To align with Mbed TLS by replacing CFG with CONFIG.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-26 07:19:32 -04:00
Tomi Fontanilles
2bedd65447 secure_storage: do not manually specify TF-PSA-Crypto include directories
This is more prone to breaking than simply inheriting all include
directories from the tfpsacrypto library.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-26 07:19:32 -04:00
Aleksandr Khromykh
ed7adfd635 bluetooth: mesh: fix solicitation data length
Commit fixes potential solicitation data length underflow.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-03-25 15:07:41 -04:00
Robert Lubos
4f09d6bcbc net: wifi: Fix static SSID logging
When logging statically configured network SSID, use the Kconfig string
instead of a SSID buffer where it was copied to, as the latter is not
guarantee to be NULL terminated.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-03-25 15:05:53 -04:00
Robert Lubos
90d9d8e12d net: wifi: credentials: Verify statically configured SSID and password
In case CONFIG_WIFI_CREDENTIALS_STATIC is used, verify the statically
configured SSID/password lengths to guarantee they don't exceed the
allowed SSID and password character limits and thus overflow credential
buffers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-03-25 15:05:53 -04:00
Fin Maaß
7b7a87c8c4 net: ethernet: do net_if_set_link_addr() in net_mgmt
do net_if_set_link_addr() for
NET_REQUEST_ETHERNET_SET_MAC_ADDRESS
in ethernet_set_config(), that way drivers don't have
to do it themself.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 10:49:59 -05:00
Markus Becker
1ac99e8ae0 net: ocpp: fix statically allocated string variables are free'd
Writable string entries in ocpp_cfg_info are free'd if non NULL in
ocpp_set_cfg_val(). Thus they should not be statically allocated.
Initialise with NULL instead.

CFG_SUPPORTED_FEATURE_PROFILE is not writable and should be fine.

Signed-off-by: Markus Becker <markushx@gmail.com>
2026-03-24 10:48:00 -05:00
Markus Becker
b49498507a net: ocpp: Properly copy ocpp_cp_info from cpi to cp
BootNotification did not transport Serial Number and other information,
because the NULL check is wrong.

Signed-off-by: Markus Becker <markushx@gmail.com>
2026-03-24 10:48:00 -05:00
Fin Maaß
b476dec78d console: use zephyr ring buffer
use zephyr ring buffer and also read and write more
than one char at a time.
Also use events to notify new rx or tx.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 07:08:13 -04:00
Fin Maaß
affed57f2b console: remove selected unneded options
CONFIG_CONSOLE_GETCHAR doesn't need
`CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS`
and `CONFIG_CONSOLE_HANDLER` since a long time.
So don't select it unnessesaryly.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 07:08:13 -04:00
Pieter De Gendt
7b0e88ac61 shell: backends: telnet: Use struct net_sockaddr_storage
A struct net_sockaddr should be considered an incomplete type, replace by
using net_sockaddr_storage.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-03-24 07:07:17 -04:00
Emil Gydesen
d66266dfa7 Bluetooth: GATT: Fix bad error from bt_gatt_attr_read_included
If `attr` or `attr->user_data` is NULL, then the include
characteristic is invalid. However the function,
bt_gatt_attr_read_included, should not return an errno value, but
a GATT error. The reason why errno cannot be used, is that the
return value is parsed through err_to_att which would make
-EINVAL become 0x16 (depending on the libc implementation),
which is an invalid ATT error code.

This was incorrectly introduced by commit
5a8189bf2a.

Changed the return value from errno to a proper GATT/ATT error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-03-24 07:07:06 -04:00
Fin Maaß
27cec4c935 net: net_if: make addr in net_if_set_link_addr() const
When providing a addr in net_if_set_link_addr() it should be
constant, as this function should not change the address
in the pointer.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 07:05:38 -04:00
Alberto Escolar Piedras
87d5f6c9d9 manifest: Update nRF hw models to latest
Update the HW models module to:
63ccab2988bf4c144b3cd324a0277e03206fa413

Including the following:
63ccab2 RADIO: Adjust Tx rampup timings
72d7680 RADIO: Correct note

AND

Adjust Bluetooth controller radio hal timings to match this new timings.

AND

Change the random seed in a very long test which is relatively sensitive
to timing, and fails due to this rampup timing change.

Repeat of note from 63ccab2:
--
IMPORTANT!: This commit changes the timing of the radio model, and
therefore requires controller SW to adjust its constants accordingly.
Even after such an adjustment it is likely some tests timing will change
marginally (if for example some advertisement event anchoring is done
as soon as possible by the controller or the like), and therefore that
some tests execution will change, and that too time sensitive test may
fail.
--

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-03-24 09:54:27 +01:00
Fin Maaß
062facbab2 net: dsa: remove NET_DSA_DEPRECATED
remove the deprecated NET_DSA_DEPRECATED.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-23 15:01:57 -05:00
Jan Kowalewski
e69cafdbb4 mgmt: hawkbit: add missing CONFIG_ prefix
Adds missing CONFIG_ prefix to HAWKBIT_USE_STATIC_CERT_TAG ifdef.

Signed-off-by: Jan Kowalewski <jkowalewski@cthings.co>
2026-03-23 15:00:10 -05:00
Tim Pambor
c84c573837 fs: shell: increase max repeat limit for tests
Increase the maximum allowed repeat count for read and write/erase
test commands from 10 to 10000. This allows for more accurate
measurements over longer test durations.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-03-23 14:57:27 -05:00
Jukka Rissanen
f611a4e4d4 net: shell: wg: Add setup command
Add a way to add private key, peer endpoint and keepalive
when setting up the wireguard connection using the shell.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
3af900c600 net: shell: wg: Use SHELL_HELP() macro for help texts
This can save flash usage by allowing string sharing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
6c27239865 net: wg: Make remaining PSA crypto helpers static
Couple of PSA crypto helper functions were not static so fix that.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
688d84b59a net: wireguard: Make blake2s private
Make blake2s private so that it cannot be used (easily) by other parts
of Zephyr codespace. The blake2s is part of the code until PSA will
have support for it. At that point the code will be removed and
replaced by the PSA calls.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
684653fd04 net: wireguard: Use PSA key management
Instead of using buffers for keys, use PSA key management to
store the keys. This is more safe than handling buffers in
the code directly.

Do some cleanup of the code structure and make the functions
in wg_psa.c static to disallow use outside of Wireguard.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
dbcf7ef5e2 net: wireguard: Support RTC with native_sim board
If running wg in native-sim, use the host clock to get the
current time. This helps to have a proper handshake when
connecting even after restarting the zephyr.exe process.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
984ddc51c1 net: wireguard: Make getting current time extensible
Allow user to provide a function that will need to get
the current time from a RTC or SNTP or similar.
Wireguard handshake replay prevention needs a monotonic
time so the application should get it from somewhere.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
7a8348af4b net: wireguard: Send network events for VPN activity
Send peer add/del network event when the peers is either added
to the system or deleted from the system.
Send VPN connected / disconnected event when a VPN connection
is successfully established or the peer connection is disconnected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
d09cee002f net: shell: wg: Print detailed peer information
The "net wg show 1" will show detailed information of the peer
id 1. This is useful when debugging connectivity issues.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
d4020814e2 net: shell: wg: Add VPN statistics support
Show VPN statistics support if enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
14ced6a59f net: wireguard: stats: Add statistics support
Collect Wireguard VPN statistics and allow user to fetch it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
cf40236791 net: shell: Add Wireguard VPN support
Add commands to manipulate Wireguard connectivity.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
bcffe6a0e1 net: wireguard: Add crypto support
The crypto code is taken from wireguard-lwip project at
https://github.com/smartalock/wireguard-lwip
and is BSD-3-Clause licensed code.

The Blake2 RFC 7693 and XChaCha20 (from
https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha-03)
cannot currently use PSA APIs.

The XChaCha20 is found in PSA 1.2 but Zephyr is not yet using that
version.

All the other crypto usage is converted to use PSA APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00