Commit graph zephyr/subsys
Author SHA1 Message Date
Siratul Islam
5565837752 fido2: Introduce PSA API
- Add PSA crypto for makecredential

Signed-off-by: Siratul Islam <email@sirat.me>
2026-06-15 18:32:42 -04:00
Siratul Islam
0a39fcfdf9 fido2: implement makecredential cbor decoding
- Add CBOR decoding for makecredential

Signed-off-by: Siratul Islam <email@sirat.me>
2026-06-15 18:32:42 -04:00
Siratul Islam
2ec27f8fed fido2: implement core and getInfo
- Implement the authenticatorGetInfo path
- Add CBOR encoding for getInfo
- Register the subsystem in CMake

Signed-off-by: Siratul Islam <email@sirat.me>
2026-06-15 18:32:42 -04:00
Siratul Islam
05d87c0fb9 fido2: add FIDO2/CTAP2 authenticator subsystem Kconfig
Add the subsys directory structure and Kconfig symbols

Signed-off-by: Siratul Islam <email@sirat.me>
2026-06-15 18:32:42 -04:00
Anas Nashif
380f951c08 ztest: add ztest_param_inst linker section to unit_testing board
The unit_testing board uses a custom linker script (ztest_unittest.ld)
that collects the STRUCT_SECTION-based lists needed by the ztest
framework.  The ztest_param_inst struct, placed in
._ztest_param_inst.static.* sections via STRUCT_SECTION_ITERABLE, was
not included, which caused link failures when
ZTEST_INSTANTIATE_TEST_SUITE_P was used in a unit test:

  undefined reference to _ztest_param_inst_list_start
  undefined reference to _ztest_param_inst_list_end

Add the .data.ztest_param_inst_area section alongside the existing
suite, unit-test, and test-rule sections so that parameterized tests
work correctly on the unit_testing platform.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
cc212fbb0e ztest: treat pass+skip==run as PASS in suite summary
When a parameterized ZTEST_P function has invocations that are a mix
of TC_PASS and TC_SKIP (with no TC_FAIL), the suite summary previously
classified the test as FLAKY and reported spurious failures.

The root cause is that the summary helpers compared only pass_count to
run_count to determine TC_PASS, ignoring skip_count.  With parameterized
tests that legitimately skip some parameter values at runtime (e.g.
test_timespec_from_timeout skips cases not applicable to the exact
conversion path), the result was:

  FLAKY - [suite.test] - (Failed N of M attempts)

Fix both __ztest_show_suite_summary_oneline and
__ztest_show_suite_summary_verbose to use the condition

  pass_count + skip_count == run_count

instead of the stricter pass_count == run_count.  A test function is
PASS when every invocation either passed or was explicitly skipped;
FLAKY is reserved for functions that have at least one real failure.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
945fbc3205 ztest: support multiple ZTEST_INSTANTIATE_TEST_SUITE_P per test function
The dispatch function z_ztest_run_test_dispatch previously found only the
first registered ztest_param_inst matching (suite, test_name) and ignored
all subsequent instantiations.  This prevented a single ZTEST_P function
from being reused across different parameter sets.

Replace the single-match helper z_ztest_find_param_inst with an inline
STRUCT_SECTION_FOREACH loop in z_ztest_run_test_dispatch.  For each
matching ztest_param_inst, the full values loop is executed in order.
FAIL_FAST and critical-error short-circuit via goto to exit both loops
cleanly.  Non-parameterized behaviour (no matching inst) is unchanged.

This enables one ZTEST_P body to serve as the dispatch target for
multiple ZTEST_INSTANTIATE_TEST_SUITE_P calls with different instance
names, each carrying an independent struct ztest_param_values.  Tests
that already use a single instantiation continue to work as before.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
d041ea4f9d ztest: add runtime-generated parameter support for ZTEST_P
Add two new macros for value-parameterized tests whose values are
computed at runtime rather than from a compile-time array or formula:

  ZTEST_DEFINE_PARAM_GENERATOR(name, type, count, gen_cb)
  ZTEST_DEFINE_PARAM_GENERATOR_WITH_SETUP(name, type, count,
     setup_cb, gen_cb)

The gen_cb callback has the same signature as the existing value_at_cb
(void (*)(size_t index, void *out)) so no new dispatch machinery is
needed.  gen_cb may read any runtime state: random numbers via
sys_rand32_get(), hardware register values, output of a custom
algorithm, etc.

The _WITH_SETUP variant adds a setup_cb (void (*)(void)) that is
called once before the dispatch loop begins.  This is the canonical
place to seed a PRNG or reset any stateful generator, keeping the
gen_cb itself stateless or cleanly separated from its initialisation.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
835a752e2b ztest: add ZTEST_DEFINE_PARAM_RANGE for value-parameterized tests
Add a zero-overhead range parameter source inspired by GoogleTest's
testing::Range(begin, end [, step]).  A half-open range [begin, end)
with configurable step can now be declared and used without allocating
a backing array:

  ZTEST_DEFINE_PARAM_RANGE(even_vals, int, 0, 10, 2);
  ZTEST_INSTANTIATE_TEST_SUITE_P(evens, my_suite, my_test, even_vals);

This yields five invocations with values {0, 2, 4, 6, 8}.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
7d936323da ztest: show parameter instance and index in test output
When a ZTEST_P test is dispatched with multiple parameter values the
console output previously repeated the same test name for every
invocation, making it impossible to tell which parameter value caused
a failure at a glance.

Format a unique display name for each parameterized invocation using
the same bracket convention as Google Test:

  test_name[instance_name/N]

where N is the 0-based index, or a custom label returned by the
optional name_cb callback:

  test_name[instance_name/custom_label]

The display name is stored in a 128-byte buffer inside the existing
z_ztest_param_ctx struct and is used only by TC_START() and
Z_TC_END_RESULT() inside run_test(); the base test->name is unchanged
everywhere else (stats, verbose summary).

Non-parameterized tests are not affected: the display_name buffer is
cleared before each plain run_test() call.

The Twister Test harness test_case_start_pattern is relaxed from the
character-class [a-zA-Z0-9_-]+ to \S+ so it can parse the new
[instance/N] suffix; the end-of-test pattern already used \S* and
requires no change.

Before:
  START - test_param_index
   PASS - test_param_index in 0.000 seconds
  START - test_param_index
   PASS - test_param_index in 0.000 seconds

After:
  START - test_param_index[idx_check/0]
   PASS - test_param_index[idx_check/0] in 0.000 seconds
  START - test_param_index[idx_check/1]
   PASS - test_param_index[idx_check/1] in 0.000 seconds

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
dca09f5d7a ztest: add value-parameterized test infrastructure
Introduce a first-class value-parameterized test mechanism (ZTEST_P)
that works like GoogleTest TEST_P / INSTANTIATE_TEST_SUITE_P:

- A test body declared with ZTEST_P is executed once per registered
  parameter value; inside the body the current value is obtained
  through ztest_get_current_param() / ZTEST_GET_PARAM(type).

- The suite fixture returned by setup() is passed as the 'data'
  argument and is completely independent from the parameter; it is
  never overwritten (root cause of the previous misuse of ZTEST_P).

New public API in ztest_test.h:

  struct ztest_param_values    -- describes a typed value array
  struct ztest_param_inst      -- links a value set to a (suite, test) pair

  ZTEST_DEFINE_PARAM_VALUES(name, type, ...)
    Declare a static value set from literal values.

  ZTEST_DEFINE_PARAM_VALUES_ARRAY(name, array)
    Declare a static value set from an existing array.

  ZTEST_INSTANTIATE_TEST_SUITE_P(inst, suite, fn, values)
    Register a ztest_param_inst entry in the ztest_param_inst
    linker section; the runner dispatches once per value.

  ztest_get_current_param()        const void *  current value
  ZTEST_GET_PARAM_PTR(type)        const type *  typed pointer
  ZTEST_GET_PARAM(type)            type          typed value
  ztest_get_current_param_index()  size_t        zero-based index
  ztest_get_current_param_size()   size_t        element size
  ztest_has_current_param()        bool          is a param active?

New internals in ztest.c:

  struct z_ztest_param_ctx  -- per-invocation parameter context global
  z_ztest_find_param_inst() -- O(n) lookup over ztest_param_inst section
  z_ztest_run_test_dispatch() -- per-test dispatch; loops over values

The fixture-overwrite path ("if (param != NULL) { data = param; }")
is removed; the legacy 'param' argument of z_ztest_run_test_suite
and related internal functions is kept for ABI compatibility but
marked ARG_UNUSED.

The linker script gains Z_LINK_ITERABLE(ztest_param_inst) so the
start/end symbols required by STRUCT_SECTION_FOREACH are emitted.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Anas Nashif
c3151bdca6 llext: apply workaround for cortex_r on exported symbols
temporary work around issue with cortex_r5 and ARM EABI mem helper
functions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:16:50 -04:00
Anas Nashif
33674b7de8 llext: export: arm mutually exclusive to arm64
ARM and ARM64 are mutually exclusive, so no need for the check.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:16:50 -04:00
Emil Gydesen
c962879dcf Bluetooth: BAP: Shell: Don't clear do_plc in the middle of SDU
The do_plc applies to the entire PLC, and not the individual frames,
so we should not clear it after doing PLC on the first frame.

Additionally this will now also do a memset after k_mem_slab_alloc
to avoid having to clearing data manually before free'ing it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-15 12:14:33 -04:00
Emil Gydesen
cb03ae6453 Bluetooth: BAP: Shell: Fix bug when updating USB streams
Since update_usb_streams rely on the sh_stream->rx to determine
whether to update the streams, we shall not clear that before calling
update_usb_streams

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-15 12:13:53 -04:00
Emil Gydesen
dbefc84380 Bluetooth: BAP: Shell: Print when codec_cfg was updated
Add calls to print_codec_cfg whenever the codec configuration
data or metadata may be changed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-15 12:13:42 -04:00
Peter Mitsis
77aa26d8b9 logging: Validate z_log_msg_static_create()
Adds validation logic to z_vrfy_z_log_msg_static_create() so that it
is no longer merely a pass-through.

Assisted-by: GitHub Copilot:GPT-5.4
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2026-06-15 12:12:36 -04:00
Carlo Caione
06fa8fa438 input: bump thread stack size default on 64-bit
1024 bytes are not enough for the event dispatch chain on 64-bit platforms
and the input thread silently overflows its stack.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-06-15 10:24:27 +02:00
Emil Gydesen
f3e11cc51e Bluetooth: Audio: Shell: Rename CONTEXT and LOCATION with DEFAULT
Suffix the LOCATION and CONTEXT macros with DEFAULT to make it
clearer that these are just the default value, since both the
location and context are configurable at runtime.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-15 10:23:52 +02:00
Anas Nashif
aa31c8a69a llext: export ARM EABI mem helper functions
On AArch32 the compiler may lower memcpy()/memmove()/memset() and
zero-initialization to the ARM EABI run-time helpers (__aeabi_memcpy,
__aeabi_memset, __aeabi_memclr and their 4/8-byte-aligned variants)
instead of calling the C library functions directly. Which helpers are
emitted is compiler dependent: Clang frequently uses the aligned
__aeabi_memset4 / __aeabi_memclr4 variants where GCC emits direct
memset() calls.

Extensions built with such a compiler reference these helpers, but they
were not part of the exported symbol table, so loading failed with
'Could not find symbol __aeabi_memset4'. Export the full set (guarded to
AArch32) alongside the existing LIBC mem* exports. The helpers are
provided by the compiler run-time (libgcc/compiler-rt); EXPORT_SYMBOL
takes their address, which pulls the definitions into the image.

Fixes tests/subsys/llext llext.readonly_mpu (test_load_unload_veneer)
when built with the LLVM toolchain on mps2/an385.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 10:23:34 +02:00
Anas Nashif
7ea932d6ae llext: fix symbol lookup ordering detection in llext_find_sym
Commit 8721af0e2a added binary-search support for the built-in symbol
table, gated on a runtime check that walks the llext_const_symbol section
and decides whether it is sorted by name. The check is broken: it sets

	ordering_state = 1;

unconditionally after the scan loop, clobbering the 'ordering_state = -1'
that is written when an out-of-order pair is found. As a result every
lookup uses binary search, even though the llext_const_symbol iterable
section is emitted in link order and is generally not sorted by name.
Binary search over an unsorted table silently fails to find symbols that
are present.

This went unnoticed because the needed symbols happened to be found
anyway, but adding more exported symbols changes the table layout and
makes valid lookups fail (e.g. a loaded extension referencing an exported
__aeabi_* helper reports 'Could not find symbol').

Move the optimistic 'sorted' assignment before the loop so a detected
inversion correctly downgrades to the linear scan fallback.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 10:23:34 +02:00
Hake Huang
368350f35e fs: fat_fs: add alignment to io buffers
add default alignment for default io buffers

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2026-06-15 10:20:10 +02:00
Henrik Brix Andersen
f4d9cd0d26 testsuite: include: zephyr: fff_extensions: reformat file
Reformat the FFF extensions header using clang-format to improve
readability.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-06-14 09:53:00 -07:00
Johan Hedberg
494283d469 Bluetooth: Host: GATT: Fix missing check for minimum read response size
There's a for loop in parse_read_std_char_desc() that'll go on forever if
rsp->len is 0. Add a minimum length check to the beginning of it to avoid
this issue.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-06-14 09:52:32 -07:00
Xudong Zheng
1b93c8b973 Bluetooth: Controller: Fix timer start without LLL prepare at margin
This workaround addresses an assert that appears when nRF52 hardware
running as central connects to a peripheral with certain connection
parameters.

Fixes #106450

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2026-06-14 15:32:51 +02:00
Emil Gydesen
0d3ac89a50 Bluetooth: BAP: Fix bad releasing state checks
The relasing state can go to IDLE or CODEC_CONFIGURED but
was defined to only allow IDLE or QOS_CONFIGURED.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 21:46:09 +02:00
Emil Gydesen
fb892aaa42 Bluetooth: BAP: SD: Fix log of wrong err value
The `err` variable was overwritten by the k_mutex functions
before being logged, so it did not log the actual error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 21:45:32 +02:00
Lauren Murphy
eb799a4e05 llext: add bounds to init / fini fn_table size
The fn_table in call_fn_table is a VLA on the stack whose
length derives from the unverified sh_size of preinit, init
and fini sections. An abnormally large or incorrect sh_size
could cause the the loader's stack to overflow or be exhausted.
Also, the fn_table often has a length of 0, which is undefined
behavior per the C standard. These issues are resolved
by this patch, which doesn't allocate fn_table when the
length would be 0, and sets the size of fn_table at
CONFIG_LLEXT_MAX_FUNCTION_TABLE_ENTRIES.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Lauren Murphy
78ca8d815a llext: add bounds checking to llext_string
Add bounds checking validation to llext_string with
NULL return, remove prevalidation of section and symbol
names in llext_validate_sections_name and
llext_count_export_syms, and add null guards for
all callers of llext_section_name and llext_symbol_name.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Anas Nashif
106540afbd llext: bound-check r_offset in Xtensa PLT relocatable branch
The PLT relocation loop has two branches depending on whether the
ELF is relocatable (tgt != NULL) or shared/dynamic (tgt == NULL).

The shared branch already validates r_offset via llext_file_offset(),
which returns -ENOEXEC if the address falls outside every loaded
section. The relocatable branch applied the relocation at
sect_base + r_offset with no corresponding check, so a
RELA entry with an out-of-range r_offset could cause an
out-of-range write at link time.

Add the same style of guard to the relocatable branch: reject any
entry whose r_offset >= tgt->sh_size (the size of the target
section) with a log message and continue, consistent with how
the sibling branch handles invalid offsets.

While we're here, change several non-erroring LOG_ERRs to
more appropriate LOG_WRNs.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Anas Nashif
b0cda7f5e6 llext: validate st_shndx before indexing sect_hdrs in copy_symbols
llext_copy_symbols() used each ELF symbol's st_shndx directly to
index ext->sect_hdrs[] and, through llext_loaded_sect_ptr(), the
ldr->sect_map[] array. Both arrays are sized e_shnum. The only
existing gate was != SHN_UNDEF, so a st_shndx = 0xFFFE
(or any value >= sect_cnt) would cause an out of bounds read of
both arrays.

The relocation path (llext_lookup_symbol) already guards this with:

  (sym->st_shndx < ldr->hdr.e_shnum) &&

Apply the equivalent discipline to the load path: reject any symbol
whose shndx >= ext->sect_cnt with -ENOEXEC before the first array
access. Because sect_cnt is always much smaller than SHN_LORESERVE
(0xff00), this single test also covers all reserved indices
(SHN_ABS, SHN_COMMON, etc.) that are not valid section array
indices.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Anas Nashif
d6ce2e7178 llext: validate pos in llext_buf_peek and guard NULL callers
llext_buf_peek() returned buf+pos with no bounds check. ELF-header-
derived offsets (e_shoff, per-section sh_offset) flow directly into
pos; a large offset would result in a pointer well past the end of
the supplied buffer during module load.

The companion llext_buf_read() already clamps via MIN(); apply the
same discipline to llext_buf_peek(): return NULL when pos >= len.

Three call sites did not guard the NULL return, and have been fixed:

  - llext.c: section-name strcmp in llext_find_section_by_name()
    used the peek result without a NULL check; add one, returning
    -ENOEXEC

  - llext_link.c: the CONFIG_CACHE_MANAGEMENT detached-section loop
    passed the peek result directly to sys_cache_data_flush_range()
    without checking; add a NULL guard that returns -ENOEXEC.

  - llext_load.c: llext_map_sections() didn't dereference the null,
    but passed the result to INSTR_FETCHABLE without checking;
    add a NULL guard that returns -ENOTSUP

All other llext_peek() callers already check for NULL and are
unaffected.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Anas Nashif
d8cb02b11d llext: validate sh_info before indexing sect_map in load pass
In llext_map_sections(), relocation section headers use sh_info as an
index into sect_map[] to find the target section's memory region and
mark it as having relocations. No bounds check was performed before
this access. The equivalent guard already exists in llext_link()
at the start of the relocation loop. Add the same check here,
rejecting the module with -ENOEXEC if sh_info is out of range,
consistent with how llext_link() handles the same condition.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-06-12 21:43:53 +02:00
Emil Gydesen
3877dead16 Bluetooth: BAP: UC: Add missing sys_cpu_to_le16 for SDU
Add missing sys_cpu_to_le16 when assigning SDU size to the QoS
configure operation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 15:46:51 +02:00
Emil Gydesen
5a90383263 Bluetooth: Audio: apply U suffix to unsigned integer literals
Apply the U suffix to unsigned integer literal constants used in
contexts involving unsigned types (uint8_t, uint16_t, uint32_t,
uint64_t, size_t, etc.) with coding guideline 40  which requires that
"A u or U suffix shall be applied to all integer constants that are
represented in an unsigned type".
In addition to this requirement, this commit also ads U to any unsigned
literal integer for the sake of completeness.

Changes are limited to literal values in assignments, initializations,
comparisons, and for-loop bounds where the context is unambiguously
unsigned.

Assisted-by: GitHub Copilot:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 15:46:35 +02:00
Emil Gydesen
af3d342f65 Bluetooth: BAP: Shell: Make it easier to copy broadcast IDs
The broadcast ID is printed in the shell various places. Often the
shell user wants to copy this value and use it for future commands.

Remove any following commas, so that the user can easier click-to-mark
the value to copy it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 15:34:28 +02:00
Robert Lubos
77107042b3 net: core: Initialize ARP during network initialization once only
The ARP module initialization is global, i.e. should only be done once
during system boot, there's no reason to do this from ethernet_init()
which is called per-interface. This could lead to multiple ARP module
initializations if there are multiple ethernet interfaces in the system,
or even worse, no intialization at all. This happened in some tests, as
some boards enabled Ethernet L2 (and thus ARP) but no actual Ethernet
interface by default.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-06-12 15:33:47 +02:00
Robert Lubos
29581d586f net: tls_credentials: Fix uninitilized mutex
credentials_lock in tls_credentials_trusted.c was not initialized before
use.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-06-12 15:33:47 +02:00
Benjamin Cabé
8e8dd62cf3 net: dns: initialize dispatcher context mutex on register
dns_socket_dispatcher.lock was used without k_mutex_init(), which
fails once CONFIG_ASSERT mutex checks are enabled (e.g. mDNS tests).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-06-12 15:33:47 +02:00
Jukka Rissanen
de6f08e57c net: ptp: fix sockaddr handling in transport_socket_open()
transport_socket_open() had two related problems with how it handled
the socket address:

1. Reading addr->sa_family through a struct net_sockaddr * pointer
   triggered a GCC -Werror=array-bounds= diagnostic when the function
   was inlined into transport_udp_ipv4_open(). The compiler could see
   that the underlying object was struct net_sockaddr_in (8 bytes)
   while struct net_sockaddr can be up to sizeof(struct
   net_sockaddr_in6) wide when CONFIG_NET_IPV6 is enabled. The access
   is safe at runtime because sa_family is the first field in every
   sockaddr variant, but the inliner-visible type mismatch made GCC
   report an out-of-bounds subscript. Pass the address family in as an
   explicit argument so the family no longer has to be read back
   through the over-wide pointer.

2. zsock_bind() was called with sizeof(*addr), which evaluates to
   sizeof(struct net_sockaddr) which is the generic, largest-possible size.
   For an IPv4 socket this passes a length larger than the actual
   struct net_sockaddr_in. Add a net_socklen_t addrlen parameter to
   transport_socket_open() and have each caller supply the size of its
   concrete sockaddr struct.

Both the IPv4 and IPv6 callers are updated to pass the family and the
correct struct size.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-12 15:33:23 +02:00
Anas Nashif
a3de885244 net: context: fix stack-use-after-scope in context_sendto()
When CONFIG_NET_IPV4_MAPPING_TO_IPV6 is enabled and a sendmsg() call
targets a v4-mapped IPv6 address, the code builds a temporary
struct net_sockaddr_in to hold the unwrapped IPv4 destination and
stores a pointer to it in dst_addr.  The variable was declared inside
the else-if (family == NET_AF_INET) block, so it went out of scope as
soon as that block exited.  dst_addr then pointed to freed stack memory
when context_setup_udp_packet() dereferenced it later.

Fix by hoisting the 'mapped' variable to function scope so its
lifetime covers the entire context_sendto() call.

Detected by AddressSanitizer (stack-use-after-scope) when running
tests/net/socket/udp on native_sim with ASAN enabled.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-12 15:33:23 +02:00
Emil Gydesen
ff26f33f35 Bluetooth: BAP: UC: Add check for stream->group for QoS notification
If the server wrongly sends us a QoS state notification before
the stream was ever added to a group, we should just ignore it
rather than hitting the assert or dereferencing the group
later.

Additionally, LOG_ERR should not be used when validating input
from a remote device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-12 15:31:54 +02:00
Flavio Ceolin
2e0f9cf05b net: sockets: fix TOCTOU in recvmsg/sendmsg
z_vrfy_zsock_sendmsg() and z_vrfy_zsock_recvmsg() copy the user
msghdr into msg_copy but then re-read msg->msg_iovlen (and other
fields) live to size the allocation, bound the loop, and gate the
writeback. A racing user thread can inflate msg_iovlen between
reads, causing the verifier loop to write past the kernel iov
shadow buffer.

Copy the msghdr first and use msg_copy for every later decision.
Save the original user iov pointer and copy each iovec entry
atomically so iov_base and iov_len cannot be raced apart.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2026-06-12 10:05:49 +02:00
Antoni Duda
2ee94b6b68 usb: cdc_acm: device_next: Mitigate posix ECHO issues
On linux the tty is opened in ECHO mode by default causing any data sent
immidiately after boot to be looped back into rx. This was mitigated in
old implementation in the commit 0127d000a2
("usb: device: cdc_acm: Use ZLP to detect initial host read").
The mitigation works by enqueing a ZLP. When the ZLP is consumed by the
host it means that it started reading. The patch then waits for some
time before sending actual payload. This gives the host application time
to switch off the ECHO mode.

This commit introduces analogous solution to device_next.

Signed-off-by: Antoni Duda <antoni.duda@nordicsemi.no>
2026-06-12 07:49:59 +02:00
Benjamin Cabé
ed62e8942c net: mcp: select PSA_CRYPTO for HTTP transport
MCP_TRANSPORT_HTTP selects MBEDTLS and PSA_WANT_ALG_SHA_1, which now
depend on PSA_CRYPTO (since 5ef6b3ae46).

That was not required when MCP landed because MBEDTLS could be enabled
without PSA_CRYPTO; the resulting Kconfig warnings now fail CI.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-06-12 00:24:28 +02:00
Jukka Rissanen
2a586030bf net: quic: Re-advertise flow control limits on loss
MAX_DATA and MAX_STREAM_DATA carry the most recent flow-control limit,
but unlike STREAM frames they were not retransmitted when lost. If such
an update was lost while a peer was flow-control blocked, the peer had
already sent STREAM_DATA_BLOCKED for the stale limit (and does not repeat
it), so the window was never reopened and the connection deadlocked. This
was seen under packet loss in the net.quic retransmission test, which
hung indefinitely.

Make quic_detect_lost_packets_locked() report whether any in-flight
packet was declared lost, and when so re-advertise the current connection
MAX_DATA and per-stream MAX_STREAM_DATA after the ACK is processed
(RFC 9000 Section 13.3). Streams are snapshotted under contexts_lock and
the updates are sent with the lock released, matching
handle_stream_data_blocked_frame().

Tested with tests/net/lib/quic (net.quic) under 10% packet drop on
native_sim and qemu_x86; the retransmission test now completes.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-11 15:04:20 -04:00
Pieter De Gendt
ecda2fe40b sensing: use STRUCT_SECTION_FOREACH_REVERSE in for_each_sensor_reverse
Replace the open-coded reverse loop with the new iterable section
helper.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-06-11 15:03:10 -04:00
Holt Sun
2dd968eca8 doc: pm: align locked-resume wording
Use behavior-first wording in the PM API notes when describing the
locked-resume contract. This keeps the durable text focused on the
case where system PM keeps interrupts locked across resume, while
keeping CONFIG_PM_STATE_SET_IRQ_LOCKED as the current selector.

Shorten duplicated zero-latency interrupt details in the system PM
page and Kconfig help by referring readers to the ZLI documentation.
Also keep the ARM IRQ comment focused on the PM-wake-safe contract.

No behavior change. Validated with git diff --check.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-06-11 15:02:52 -04:00
Holt Sun
edda8cfb52 doc: pm: scope locked-resume ordering to maskable interrupts
The locked-resume ordering guarantee covers only interrupts that
arch_irq_lock() can mask. On Cortex-M Mainline that lock is a BASEPRI
threshold, so zero-latency interrupts (IRQ_ZERO_LATENCY) run above it
and are outside that ordering.

Document that a zero-latency ISR used with PM must be PM-wake-safe, or
that its interrupt source must be masked or disabled while the system
state does not allow the ISR to execute.

No behavior change. Validated with git diff --check.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-06-11 15:02:52 -04:00
Hui Bai
b31711769f net: l2: wifi: Add SSID protection parameter for STA and AP.
Add new parameter -C to enable or disable SSID protection in wifi connect
and wifi ap enable commands. The SSID protection is disabled by default.

Signed-off-by: Hui Bai <hui.bai@nxp.com>
2026-06-11 15:02:14 -04:00