Implement the QUIC TLS 1.3 external-PSK path so the stack no
longer derives early_secret from a zero placeholder when a PSK
is configured.
Store PSK credentials in the TLS context, build and verify
pre_shared_key binders, advertise psk_dhe_ke and early_data in
ClientHello, and emit the ServerHello PSK selection when the
server accepts the offered identity.
Also make the handshake fall back to the non-PSK key schedule
when the server declines PSK, and skip the certificate flight
entirely for accepted PSK handshakes.
Add a focused QUIC PSK end-to-end test.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add the transport and TLS scaffolding needed for QUIC 0-RTT
support without enabling early data yet.
Introduce QUIC_SECRET_LEVEL_EARLY and a dedicated early crypto
context, map 0-RTT packets to that context, and keep 0-RTT on
the application packet number space as required by RFC 9001.
Also add 0-RTT long-header construction and extend the helper
paths that choose crypto contexts, packet numbers, TX stats,
and debug key logging so later PSK and ticket patches can build
on the right plumbing.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The gcov BSS linker fragment used the MPU_ALIGN() macro when
CONFIG_USERSPACE is enabled on both ARM and ARM64. That macro is only
defined by the Cortex-M and Cortex-A/R MPU linker scripts; ARM64
isolates user regions with the MMU and never defines it, so an ARM64
build with coverage and userspace failed to link with
"cannot find MPU_ALIGN".
Restrict the MPU_ALIGN() path to non-ARM64 targets. ARM64 falls back
to aligning on _region_min_align (the MMU page size), which is the
correct granularity to keep the coverage counters in their own page so
they can later be granted user access.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add state validation check in the L2CAP BR/EDR receive path to ensure
channels are in a valid connected state before processing incoming
data.
The change adds a check after the fixed channel validation to verify
that the channel state is at least `BT_L2CAP_CONNECTED` before
proceeding with data reception. If the channel is in an earlier state
(`CONNECTING` or `DISCONNECTED`), an error is logged and the packet is
dropped.
It prevents potential issues from processing data on channels that
are not yet fully established or are in the process of being torn down,
improving the robustness of the L2CAP receive path.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Refactor the fixed channel accept functions to use channel state
for direct check if the channel is available instead of checking
`conn` field of channel. And also refactor the fixed channel
accept functions to use connection index for direct lookup instead
of iterating through the pool arrays.
The changes affect the L2CAP BR signaling channel, connectionless
channel, and SMP BR channel accept functions.
The functions now check if the channel is in the `DISCONNECTED`
state before accepting a new connection, returning `-EBUSY` if the
channel is not idle. This ensures proper channel state validation
and prevents reuse of channels that are still in use.
Additionally, instead of searching through the entire pool to find
an available channel context, the code now uses `bt_conn_index()` to
directly access the corresponding entry in the pool array.
The L2CAP BR fixed channel connection now also sets the channel
state to CONNECTING, ensuring proper state transitions.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add proper state management to Bluetooth Classic L2CAP fixed channel
connection by setting the channel state to `CONNECTED` before invoking
the connected callback.
The change ensures that fixed channels follow the same state
transition pattern as other L2CAP channel types. When a fixed channel
is connected, the state is now explicitly set to `BT_L2CAP_CONNECTED`
before calling the channel's connected callback.
The changes ensure the channel state accurately reflects its lifecycle
status.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Optimize the L2CAP BR/EDR dynamic CID allocation by using a static
counter to track the last allocated CID instead of always starting
from the beginning of the range.
The change introduces a br_cid_next array that maintains the position
of the next CID to allocate for each connection. The allocation now
searches from the last allocated position through the range, wrapping
around if needed. This reduces the search time for available CIDs in
scenarios with multiple active channels by avoiding repeated scans of
already-allocated CIDs at the start of the range.
Additionally, this modification has the advantage of preventing a
recently disconnected CID from being immediately reassigned to a new
channel. This avoids data from the channel disconnection process being
sent to the newly assigned channel.
The allocation still validates that CIDs are not in use by checking
against bt_l2cap_br_lookup_rx_cid() before assignment, maintaining the
same correctness guarantees as the previous implementation.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The connection pointer is already cleared by the L2CAP layer when the
channel is disconnected, so there's no need to manually set it to NULL
in the AVCTP disconnect callback.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The connection pointer is already cleared by the L2CAP layer when the
channel is disconnected, so there's no need to manually set it to NULL
in the AVDTP disconnect callback.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Universal Serial Bus Specification Revision 2.0 does not differentiate
between "stack errors" and "protocol errors". 8.5.3.1 Reporting Status
Results lists three control transfer outcomes:
* Function completes (ZLP/ACK)
* Function has an error (STALL)
* Function is busy (NAK)
If the control transfer fails, the device should respond with a STALL
handshake. In addition to protocol errors, which are reported using
errno values, the new device stack uses control transfer handler
return values as indicators for unrecoverable errors. Handlers that
wish to send a STALL handshake must set an errno value and return 0.
The idea of using both errno and return values was to propagate
unrecoverable errors to the user application, which would then shut
down and re-enable the stack. However, this approach is not unambiguous
for users and causes non-compliant timeout behavior when a handler
returns a non-zero value.
Make the stack always behave standards-compliant by removing errno
usage and passing the result directly via the control handler return
value. For now, keep the errno detection to output a deprecation warning.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
- This seems like a break of abstractions.
- The UDP transport doesn't need access to it.
- This makes transport tests easier.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
New command is added to remove P2P persistent network(s).
wifi p2p persistent_remove <idx>
If idx >= 0, check existance of persistent network with the given idx
and remove it if exists.
If idx = -1, remove all saved persistent networks.
Signed-off-by: Hui Bai <hui.bai@nxp.com>
Add persistent support in P2P connect command
Add new parameter -a which indicates adding new persistent group.
No argument. No persistent group will be added without -a.
Signed-off-by: Hui Bai <hui.bai@nxp.com>
The persistent parameter doesn't work when trying to add persistent
group in wifi p2p group_add command. The fixes are as below:
1. Add new parameter -a to indicatie adding persistent group (default
false).
2. Parameter -a has high priority than -p. This which means if both -a and
-p parameters are adding in group_add command, -a will finally take
effect.
3. If -a is added, will issue command "set persistent_reconnect 1" to ctrl
interface so that the persistent group could be re-invoked by other
peers.
4. Added sanity check if persistent index is indicated. Check if the
persistent group is exist or not. If not exist, print error log.
Signed-off-by: Hui Bai <hui.bai@nxp.com>
Add the on-target support needed to attribute code coverage to
individual Ztest test cases.
gcov_coverage_dump_tagged() emits coverage tagged with a caller-supplied
label so a dump can be attributed to one producer. The console transport
appends the tag to the GCOV_COVERAGE_DUMP_START marker; the semihosting
transport writes each .gcda to "<filename>@@<tag>" so several isolated
dumps coexist next to the matching .gcno. A NULL tag reproduces the
previous, untagged behaviour, and gcov_coverage_dump() and
gcov_coverage_semihost() are retained as NULL-tag wrappers.
CONFIG_ZTEST_COVERAGE_PER_TEST registers a ZTEST_RULE that resets the
gcov counters before each test and dumps a tagged "<suite>.<test>"
artifact after it. Objects with no coverage since the reset are skipped
from these per-test dumps, which greatly reduces both the on-target dump
size and the later host-side processing.
While reworking the semihosting path, close the file descriptor on every
iteration instead of only for the last object, fixing a pre-existing
descriptor leak that per-test dumping would aggravate.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The load_hex command shared one static buffer for the ELF
input. With LLEXT_STORAGE_WRITABLE the loader maps regions in
place, so a second load_hex overwrote the buffer the first
extension still referenced.
Allocate one buffer per load, track it by extension name and
free it on unload. Reject an already loaded name and invalid
hex input so no buffer is leaked or freed while still in use.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Add wpa3 transition disable bitmap configuration parameter.
This feature used to verify if station fallback can select
secure algorithms correctly under AP transition disable
configured.
Signed-off-by: Rex Chen <rex.chen_1@nxp.com>
Refactor SDU (Service Data Unit) length tracking in Bluetooth Classic
L2CAP to use closure-based storage instead of channel state variables.
The change introduces a new l2cap_br_closure structure that extends
the base closure with an sdu_len field, allowing SDU length to be
stored per-buffer rather than in the channel structure. This eliminates
the need for _sdu_total_len tracking in both bt_l2cap_br_chan and
bt_l2cap_br_window structures.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add doxygen warnings to PBAP authentication helper functions to inform
users that PBAP v1.x uses MD5 for authentication, which is
cryptographically weak and provides limited security.
Add the log warnings to the function. The warning Log message will be
printed when the function is being called in the running time mode.
Also add a building warning if the `CONFIG_BT_PBAP` is enabled.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
A downlink carrying only the FPending bit (no ACK, no FRMPayload and
no pending MAC answer) was dropped without notifying the application,
losing the queued-downlink hint. Dispatch a payload-less notification
whenever the frame carries an ACK or any flag worth reporting.
Assisted-by: claude-opus 4.8
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
FPort 0 is reserved for MAC commands; an application payload sent on port 0
would be encrypted with the network session key and parsed as MAC commands
by the server.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Per spec FPort 0 carries MAC commands only (encrypted with FNwkSIntKey)
and cannot be combined with FOpts MAC commands in the same frame: feed the
decrypted payload to the MAC command parser before any session state is
committed, reject frames mixing the two forms, and never deliver port-0
payload to the application downlink callbacks.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Queue the LinkCheckReq via the engine so it rides the next uplink; with
force_request mac_do_link_check() triggers the empty unconfirmed uplink
itself.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
MAC commands in FOpts eat into the maximum application payload for the
datarate. Subtract the pending FOpts length when validating an uplink and
in lorawan_get_payload_sizes(), which now returns distinct values for the
next payload and the no-FOpts maximum.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Walk the downlink FOpts with a CID/length table so known-but-unhandled
commands are skipped and a trailing LinkCheckAns is still reached;
unknown CIDs terminate parsing since their length is unknown. Commands are
processed only after MIC verification and replay checks.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Add the LWAN_REQ_LINK_CHECK engine request: the handler queues a
LinkCheckReq that the FOpts builder emits on the next uplink.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Use a positive sentinel for the confirmed-uplink retry loop so a real
-EAGAIN propagated from the TX/RX path cannot be mistaken for a retry
request.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
No functional changes in this commit.
mac_do_join() and mac_do_send() had grown into long monolithic functions.
Split frame building, downlink parsing and the retry loop into small
single-purpose helpers and group the per-transaction variables into
join_state / send_state structs.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
uart drivers, that init in POST_KERNEL and
not in PRE_KERNEL_1 can't support
CONFIG_EARLY_CONSOLE, add a Kconfig for it.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
the boot banner is printed at the end of
the init process with
``SYS_INIT(boot_banner, APPLICATION, 0);``
we don't need the early console for it.
When CONFIG_EARLY_CONSOLE is enabled,
the console will init with PRE_KERNEL_1, otherwise
with POST_KERNEL. Both are before APPLICATION.
For compatibility `EARLY_CONSOLE` will now be enabled by default,
as it was selected by the boot banner before, that is also
enabled by default.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Producers put trace packets into a single shared ring buffer under
TRACING_LOCK, which was a bare irq_lock(). irq_lock() only masks
interrupts on the local CPU, so on SMP two producers on different cores
could mutate the ring buffer concurrently and corrupt it - the buffer is
documented as single-producer and relies on the caller to serialize.
Back TRACING_LOCK/TRACING_UNLOCK with a k_spinlock instead. On SMP this
serializes producers across cores; on uniprocessor k_spin_lock()
degrades to the same interrupt-lock, so there is no added cost and
behaviour is unchanged.
Restructuring synchronous mode to emit to the backend outside the lock
was considered but not done: emitting synchronously from ISR context
with a blocking backend inherently keeps interrupts masked for the
transfer (which is why sync mode already requires a low-latency
backend), so it would not remove that property, and the extra
copy/critical-section regresses the high-rate sync UART test.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Runtime control of tracing was only possible over the UART host-command
path (CONFIG_TRACING_HANDLE_HOST_CMD). Add an optional "tracing" shell
command, behind CONFIG_TRACING_SHELL, to enable/disable emission, show
the tracing state and the dropped-packet count, and flush the backends.
It reuses tracing_set_enabled(), tracing_packet_drop_count_get() and
tracing_backends_flush() from the core.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The core resolved a single backend by name (CONFIG_TRACING_BACKEND_NAME)
into a working_backend pointer and emitted only to it. Backends already
live in an iterable section, so fan every trace packet out to the
configured backend plus any backend registered under a different name.
An out-of-tree module that adds a backend with TRACING_BACKEND_DEFINE()
then receives the same stream with no edits to the core tree; a backend
sharing the configured name (as some tests do to substitute a capture
backend) overrides it, so single-backend behaviour is unchanged.
The common single-backend case stays a direct call - the section is only
walked when a differently named backend exists - to avoid slowing
high-rate synchronous backends.
Also surface what was previously hidden: tracing_packet_drop_count_get()
for the otherwise write-only dropped-packet counter,
tracing_set_enabled() to toggle output at runtime, and an optional
flush() backend op with tracing_backends_flush(). These are used by the
tracing shell in a later commit.
tests/subsys/tracing/tracing_backend_fanout registers a second backend
and checks that it receives data.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The CONFIG_TRACING_USER backend routed only thread, ISR, idle, sleep,
timer, GPIO and RTIO hooks to overridable __weak sys_trace_*_user()
callbacks; every kernel-object hook was a no-op, so an integrator could
not observe semaphores, mutexes, message queues, etc. without forking
the header.
Widen the backend to the kernel-object hooks (condition variables,
events, mailboxes, memory slabs, message queues, mutexes, polling,
semaphores, the remaining thread hooks and work queues): each
sys_port_trace_k_*() macro now calls a typed sys_trace_k_*() trampoline
that forwards to a __weak sys_trace_k_*_user() callback. The typed
signatures were taken from the CTF backend
(subsys/tracing/ctf/ctf_top.c), which already declares them.
Object types CTF itself does not trace (queue, fifo, lifo, stack, pipe,
heap) and the net/socket hooks are left out for now; they still resolve
to no-ops via the tracing_hooks.h fallback, so this is additive. The
trampoline functions reuse the CTF sys_trace_k_* names without conflict
because tracing_user.c and ctf_top.c are never compiled together.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The format selection in <zephyr/tracing/tracing.h> is a hardcoded
not add a tracing format without editing the core tree (Percepio, though
shipped as a module, still relies on a hardcoded include).
Mirror the existing CONFIG_TRACING_BACKEND_NAME pattern for formats: add
a promptless Kconfig string CONFIG_TRACING_FORMAT_HEADER that a module
assigns (default "my_format.h" if TRACING_MY_FORMAT), and pull it in
from tracing.h with a computed #include when no in-tree format is
selected. The format header defines the hooks it records and ends by
including tracing_hooks.h so the rest fall back to no-ops.
Add <zephyr/tracing/tracing_default_hooks.h> providing the default lower
sys_trace_* layer (isr/idle prototypes resolving to the weak no-ops in
tracing_none.c, plus no-op macros for named events and system init) so a
minimal out-of-tree format does not have to reimplement it.
A backend is already pluggable through TRACING_BACKEND_DEFINE(), so
neither a custom format nor a custom backend now requires changes to the
core tree. The new tests/subsys/tracing/tracing_format_module is a
complete worked example and verifies a format supplied purely via
CONFIG_TRACING_FORMAT_HEADER is wired into the kernel hook points.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Include tracing_hooks.h at the end of tracing_test.h, after the test
backend's own hook definitions, and remove the 164 empty no-op
sys_port_trace_* defines that the canonical fallback now supplies. As
with the user backend, tracing_test.h pulls in kernel.h before defining
its hooks, so the fallback is included here at the header's end.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Include tracing_hooks.h at the end of tracing_user.h, after the user
backend's own hook definitions, and remove the 293 empty no-op
sys_port_trace_* defines that the canonical fallback now supplies.
tracing_user.h includes kernel.h (which re-enters tracing.h) before it
defines its hooks, so the fallback must be included here, at the end of
the header, rather than from tracing.h - otherwise the re-entrant
include would define the no-ops first and the real definitions below
would redefine them.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Include tracing_hooks.h at the end of tracing_sysview.h, after
SystemView's own hook definitions, and remove the 160 empty no-op
sys_port_trace_* defines that the canonical fallback now supplies. The
filled.
No functional change: every hook SystemView recorded expands as before.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Include tracing_hooks.h at the end of tracing_ctf.h, after CTF's own
hook definitions, and remove the 130 empty no-op sys_port_trace_*
defines that the canonical fallback now supplies. The #ifndef guards
keep CTF's real definitions; only the gaps are filled, so this header no
longer has to track the full hook list.
No functional change: every hook CTF defined expands exactly as before,
and the previously-undefined hooks now resolve to a no-op instead of
being absent.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
INIT-REBOOT requests omitted option 55, so strict DHCP servers did not
return DNS and other options after link down once per-interface DNS
entries were removed on NET_EVENT_IF_DOWN.
Assisted-by: Cursor:Composer
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Ensure net_arp_prepare struct net_in_addr pointer
passed to net_arp_prepare is correctly aligned to
avoid undefined behavior due to member access within
misaligned address as reported by undefined behavior
sanitizer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Use *_raw variant in is_destination_local instead of
the standard function to avoid undefined behavior due to
member access within misaligned address as reported by
undefined behavior sanitizer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Use net_ipv4_is_addr_mcast_raw in process_multicast instead of
net_ipv4_is_addr_mcast to avoid undefined behavior due to
member access within misaligned address as reported by
undefined behavior sanitizer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The HCI Set Extended Advertising Parameters command carries an
Advertising_TX_Power field, but Zephyr hardcoded it to
BT_HCI_LE_ADV_TX_POWER_NO_PREF, giving applications no way to
request a specific TX power for an extended advertising set.
Add an int8_t tx_power field to struct bt_le_adv_param together
with a new BT_LE_ADV_OPT_TX_POWER options bit. When the bit is set,
the tx_power value is passed to the controller via
le_ext_adv_param_set(). The controller selects the closest supported
level and reports the actual value back via bt_le_ext_adv_info.tx_power.
Existing code that does not set BT_LE_ADV_OPT_TX_POWER is unaffected;
the controller continues to choose the TX power freely.
Assisted-by: Augment:claude-sonnet-4.6
Signed-off-by: Sharon Lin <slin@atmosic.com>
Replace memcmp() with mbedtls_ct_memcmp() when verifying authentication
response digests to prevent timing attacks. The standard memcmp()
function may leak information about the digest through timing side
channels, allowing attackers to potentially recover the digest
byte-by-byte.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Adds LLEXT support for executing out of word granular
access instruction memory on Xtensa. This is achieved by
copying the text region onto the instruction heap
(assumed in instruction memory) but saving the
ELF address for use as the base address in
calculating relocation rel_addr (the location of the
relocation). Any rel_addr landing in the text region
is recalculated using the heap address instead.
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Signed-off-by: Anthony Giardina <anthony.giardina@intel.com>
The per-adv-sync shell commands store the selected index for the
per_adv_syncs array. The select command validated and listed adv_sets
instead, so ARRAY_SIZE could select past per_adv_syncs or show unrelated
advertiser entries.
Return immediately when per-adv-sync transfer gets an out-of-range index.
Parse the optional index with shell_strtoul() so invalid input does not
fall through to the array access.
Signed-off-by: Old Ding <ai.neo.ae86@gmail.com>