Commit graph

24,075 commits

Author SHA1 Message Date
Jordan Yates
099dd4509f lorawan: services: update fragmented transport parsing
Update the fragmented data transport parsing to always consume complete
control messages, regardless of any validation errors. Simplify the
implementation of this by defining the packets as packed structures.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-07 08:31:51 -05:00
Jordan Yates
25c395b066 lorawan: services: frag_transport: define status bits
Define status bits as enumerations, instead of using `BIT` directly in
the code.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-07 08:31:51 -05:00
Ashirwad Paswan
38763c33d1 fs: ext2: fix incorrect write length in ext2_inode_write
This commit fixes the bug by ensuring `to_write` is properly bounded.
It is now calculated as the minimum of the remaining requested bytes
(`nbytes - written`) and the remaining space in the current block
(`block_size - block_off`).

Fixes #106276

Signed-off-by: Ashirwad Paswan <ashi06712@gmail.com>
2026-04-04 10:59:13 -05:00
David J. Leach, Jr.
e3645486d1 net: ocpp: replace RPC type magic numbers with symbolic constants
Replace the hardcoded WAMP RPC type values used when encoding OCPP
messages with their corresponding symbolic constants.

- Replace '2' with OCP_WAMP_RPC_REQ
- replace '3' with OCP_WAMP_RPC_RESP

This removes magic numbers and improves human readability.

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
David J. Leach, Jr.
a1585cd5e9 net: ocpp: Protect against static analysis issue generation
Static analysis has a difficult time tracing whether a call to
ocpp_send_to_server() needs to initialize sndlock and rspsig because
the message type is set very much earlier in the program logic flow.
Note that coverity is creating a single issue for sndlock and for rspsig
in each function that calls ocpp_send_to_server() without initializing
them.

Adding a NULL test will prevent future static analysis false positives.

Fixes #100026
Fixes #100025
Fixes #100024
Fixes #100017
Fixes #100015
Fixes #100013
Fixes #100011
Fixes #100010
Fixes #100008
Fixes #100006

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
Nikhil Namjoshi
41082f40fc net: Initialize chksum variable to avoid clang build errors
This addresses clang build failure seen in
https://github.com/zephyrproject-rtos/zephyr/runs/69856219528

after PR #106578 was merged.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 14:58:06 -05:00
Zafer SEN
5f01a3d236 lwm2m: remove redundant NULL check in _INIT_OBJ_RES_INST
Drop the unnecessary _ri_ptr NULL check, as multi-instance resources
always provide a valid instance array when _ri_count > 0. This
simplifies the initialization logic and prevents compile time warrning
messages/noice.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-03 14:56:14 -05:00
Taha Benderli
517cfd37d8 net: l2: ethernet: fix order of address check
ethernet_update_tx_stats checks the multicast address first and then the
broadcast which causes the broadcast address to be treated as multicast
and not counted correctly.Fix this by checking broadcast address first,
followed by the multicast address.

Signed-off-by: Taha Benderli <taha.benderli@analog.com>
2026-04-03 23:18:26 +09:00
Nikhil Namjoshi
c12f7b566c net: Add net_pkt_skip error handling
There are several areas in the networking stack where this is missing.
So make sure we add it.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
f98624455c net: Update net_calc_chksum to return err code on failure
`net_calc_chksum` is designed to return uint16_t checksum.
Its current behavior is to return 0 checksum on error
(or on an empty payload) and a valid non zero checksum for non empty
payloads. 0 could be a valid checksum for empty payload.

So update the `net_calc_chksum` and its wrapper's definition to
return error codes.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
86fd0944c5 net: tcp: Fix potential underflow in tcp data length
tcp_options_len calculation in tcp_data_len can underflow
if th_off(th) is less than 5. This can lead to a huge
tcp_options_len value and subsequently a wrong data length calculation.
Add the checks in tcp_recv() which is a top API, so that the checks
are covered at the entry point.

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

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:13:33 +09:00
Jordan Yates
07f1481906 storage: stream: stream_flash: check size overflow
Add an initialisation time check for stream flash that the requested
offset and size does not overflow `size_t`. This in turn ensures that
`inspect_device` doesn't erroneously return `0` if the addition would
have overflowed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-03 23:11:34 +09:00
Yangbo Lu
dbdc3939e6 net: qbv_shell: fix variable without initialization
Some variables were used without initialization causing
command failure. Fixed them.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-04-03 23:10:23 +09:00
Artur Dobrynin
eeef8ad2b1 Bluetooth: Host: rotate NRPA
NRPA should be rotated every TGAP(private_addr_int)
according to spec, which is also checked in PTS.

Signed-off-by: Artur Dobrynin <artur.dobrynin@nordicsemi.no>
2026-04-01 15:12:17 -05:00
Zafer SEN
54de0d3d0f lwm2m: connmon: add Link Utilization resource support
Introduce the CONNMON_LINK_UTILIZATION resource to the Connection
Monitoring object. Add backing storage, initialize it during instance
creation, and register it in the resource table.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-01 11:52:48 -05:00
Trond F. Christiansen
3aa3b96a93 zbus: proxy agent: Remove unused code
Remove unused code related to zbus_proxy_agent_backend_desc and run-time
backend registration left over from early development.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
2026-04-01 11:49:39 -05:00
Jani Hirsimäki
a85db98380 net: iface: longest-prefix match for net_if_ipv6_addr_onlink()
Select the interface whose on-link prefix has the greatest length when
multiple prefixes match the same address. Fixes wrong iface selection
when a host has several interfaces whose on-link prefixes overlap (e.g.
a shorter prefix on one link and a longer, more specific prefix on
another). Callers that pass iface == NULL still get a boolean only; no
interface pointer is written.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2026-04-01 09:18:32 -05:00
Jukka Rissanen
97e96f2957 net: Remove experimental status from pre-emptive network threads
The support for running network TX/RX threads in pre-emptive way
was introduce in 2020. The experimental status is no longer valid
as the feature has been there for quite some time and it is being tested
also regularly by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-04-01 09:17:53 -05:00
Nicholas Cadieux
4e5cb31d32 usb_c: pe: fix PE state on DRS sender response timeout
When the SenderResponseTimer expires in PE_DRS_SEND_SWAP, PE was
unconditionally transitioning to PE_SNK_READY. This is incorrect when
the port is operating as a Source, as it should return to PE_SRC_READY.

Replace pe_set_state(dev, PE_SNK_READY) with pe_set_ready_state(dev),
which selects the correct ready state based on the current power role.

Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
2026-03-31 18:24:46 -05:00
Alexander Wachter
a03080b002 usb: usb_c: fix level of vbus check in Attached.SNK
The transition from Attached.SNK to Unattached.SNK is currently
triggered if vbus is < vSafe5V.
USB-Type C Spec R2.4 Table 4-3 defines vSinkDisconnect as
the voltage to be used for the transition from
Attached.SNK to Unattached.SNK
This commit changes the check to use the correct voltage level.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2026-03-31 18:22:17 -05:00
Ederson de Souza
d723a996eb subsys/pmci/mctp: Avoid possible race when enabling MCTP over I3C
Callback for IBI (In-Band Interrupt) was being set after enabling IBI -
which could be an issue if an IBI would be asserted in between enabling
IBI and setting the callback. This patch simply sets the callback before
enabling IBI.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Ederson de Souza
5609406614 subsys/pmci/mctp: Allow unregistering I2C target
Add a `mctp_i2c_gpio_target_unregister`, which basically calls I2C
`i2c_target_unregister`. While libmctp binds are only "started", with
no cleanup, this will be useful for tests, allowing a sequence of them.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Ederson de Souza
a8b6717816 subsys/pmci/mctp: Block on UART transfer
When sending "big messages", libmctp queues a series of packets and
calls the binding in a loop to transmit all messages. If previous
message was still being sent, transmission would fail with -EBUSY, but
libmctp wouldn't handle it.

This patch makes the UART TX blocking, so it only returns after
completion, allowing next TX to just work.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Mikhael Skvortsov
01586032e4 net: wireguard: fix PSA slot leak
Free any leftover ephemeral key from a previous unanswered initiation.

Signed-off-by: Mikhael Skvortsov <mikhael.skvortsov@gmail.com>
2026-03-31 13:55:23 -05:00
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