Adds WIFI_SECURITY_TYPE_OWE to the Wi-Fi security
enum and propagates it through management helpers,
shell, credentials library and Kconfig.
Signed-off-by: Anton Rejoe <antonrejoe@gmail.com>
Limit the number of bytes that will be copied to the DATA IN buffer in
the CDC NCM implementation.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The buf parameter in handle_download() is allowed to be NULL. Check it
explicitly before using it for the length calculation or as an argument
for the callback.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Based on spec 2025-11-25, tool support, StreamableHTTP
Signed-off-by: David Piskula <david.piskula@nxp.com>
Assisted-by: Claude:claude-opus-4-5-20251101
The TCP receiver buffer in zperf_tcp_receiver.c was previously
hardcoded to 1500 bytes, which limited throughput on fast connections.
Introduce CONFIG_NET_ZPERF_TCP_RECEIVER_BUF_SIZE as a Kconfig integer
option (default 1500, range 256 to 65535). This allows users to scale
the buffer size based on their hardware capabilities and application
requirements.
Signed-off-by: Surya Prakash T <suryat@aerlync.com>
Add Wi-Fi NAN (Neighbor Awareness Networking) support to Zephyr
including event handling, management API, and shell commands.
NAN enables devices to discover services and communicate with
nearby devices without requiring a traditional access point.
This commit includes:
- NAN management APIs and event handling
- Shell commands for NAN operations (publish, subscribe, transmit)
- Build test configuration and documentation
Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
cast uint8_t to uint32_t before << 24 to avoid signed UB
By undefined behavior sanitizer:
runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
cast uint8_t to uint32_t before << 24 to avoid signed UB in
buf_read_be32
By undefined behavior sanitizer:
runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
cast uint8_t to uint32_t before << 24 to avoid signed UB in
coap_option_value_to_int
By undefined behavior sanitizer:
runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
cast uint8_t to uint32_t before << 24 to avoid signed UB.
By undefined behavior sanitizer:
runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
cast uint8_t to uint32_t before << 24 to avoid signed UB in
clock_sync_package_callback.
By undefined behavior sanitizer:
runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
NET_CMSG_NXTHDR() only guarantees room for another control message
header; it does not guarantee room for the complete aligned element.
Check the remaining buffer before writing the payload.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Instead of just checking the lower limit, use
is_valid_num_ases to also test the upper limit.
This approach is used by all other control point operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing type check in sdp_attr_parse() before recursively parsing
data element sequences. When checking the type of the next data if it
is a sequence, it did not first check if the current type is a
sequence.
It could lead to incorrect recursive parsing when the current type is
not a sequence but the next byte was incorrectly identified as a
sequence.
Fix the issue by checking the current data type firstly.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add new optional callback that lets application decide whether Set
Report payload should be received or not. This allows applications to
stop Set Report control transfer handling during Data OUT stage.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Universal Serial Bus Specification Revision 2.0 9.2.7 Request Error
states "It is preferred that the STALL PID be returned at the next
Data stage transaction, as this avoids unnecessary bus activity.".
USB device_next implementation always attempted to receive Data OUT
stage without asking the handler if request can be handled. The only
case where the Data OUT stage was STALLed was when there was not enough
memory to allocate Data OUT buffer.
Do not automatically enqueue buffer to receive Data OUT stage. Call the
handler first with NULL buffer to determine whether the Data OUT stage
can be received. The handler will be called again after Data OUT stage
is received (it may not be called if there is not enough memory to
allocate Data OUT buffer, or if host aborts the transfer).
Modify all in-tree control transfer handlers to perform sanity check
before Data OUT stage is received. Out-of-tree classes that handle
control transfers with Data OUT stage will have to be updated. It was
chosen to implement this as a breaking change in order to not add any
new callbacks and to encourage device implementations to STALL Data OUT
stage as preferred by the USB specification.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
bt_hci_le_enh_conn_complete() obtains a reference via
find_pending_connect() but drops it immediately after the
bt_conn_connected() callback, while the function still dereferences
conn->role afterwards in the central-role scanner restart block.
Using a pointer after its reference has been dropped is a
use-after-free in API contract terms, even if in practice the
connection survives because other references (the conn array's
intrinsic reference, L2CAP, etc.) keep the object alive at this
point.
Move the bt_conn_unref() call to the end of the function so the
locally held reference outlives all uses of conn.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_avrcp_cover_art_ct_l2cap_connect() obtains a reference to the ACL
connection via bt_avrcp_ct_get_acl_conn() but then immediately drops
that reference before continuing to use the conn pointer for
bt_conn_index() and bt_bip_l2cap_connect(). Using a pointer after
its reference has been dropped is a use-after-free in API contract
terms, even if in practice the underlying connection survives because
other references (e.g. the L2CAP channel, the ACL link itself) keep
the object alive while AVRCP cover art is in use.
Move the bt_conn_unref() call to after the last use of conn on each
return path so that the locally held reference outlives all uses.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
bt_conn_unref(conn);
conn = NULL;
(and equivalent if-guarded variants) with bt_conn_drop(&conn) which
performs both operations atomically in a single step. The guard is
unnecessary because bt_conn_drop() handles a NULL pointer internally.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
bt_conn_unref(conn);
conn = NULL;
(and equivalent if-guarded variants) with bt_conn_drop(&conn) which
performs both operations atomically in a single step. The guard is
unnecessary because bt_conn_drop() handles a NULL pointer internally.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
bt_conn_unref(conn);
conn = NULL;
(and equivalent if-guarded variants) with bt_conn_drop(&conn) which
performs both operations atomically in a single step. The guard is
unnecessary because bt_conn_drop() handles a NULL pointer internally.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
bt_conn_unref(conn);
conn = NULL;
(and equivalent if-guarded or take-then-unref-then-NULL variants) with
bt_conn_drop(&conn) which performs both operations atomically in a
single step. The guard is unnecessary because bt_conn_drop() handles a
NULL pointer internally.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Add a new bt_conn_drop() function that atomically drops a connection
reference and clears the source pointer in a single step. This mirrors
the recently added net_buf_drop() API and replaces the common pattern:
bt_conn_unref(conn);
conn = NULL;
The new API handles a NULL pointer internally, so any guard around it
is unnecessary.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the manual two-step pointer transfer:
struct bt_conn *acl = iso->iso.acl;
if (acl != NULL) {
iso->iso.acl = NULL;
...
}
with bt_conn_take(), which atomically extracts the reference and clears
the original pointer in a single step.
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Extend the PTP port shell output with peer-to-peer delay information,
including the minimum Pdelay request interval, pending Pdelay sequence,
Pdelay timer state, and neighbor rate ratio.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Increase the IPv4 and IPv6 multicast address defaults when UDP P2P is
selected so PTP can join both default and peer-delay multicast groups.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Add a configurable PTP delay mechanism selection and implement the
peer-to-peer delay exchange for Pdelay_Req, Pdelay_Resp, and
Pdelay_Resp_Follow_Up messages.
Update the PTP clock delay calculation to use peer link delay in P2P
mode, track neighbor rate ratio from Pdelay samples, and route Pdelay
traffic to the peer-delay multicast addresses for UDP and L2 transports.
Reject unsupported one-step Pdelay_Resp messages, invalid Pdelay
exchanges, missing event RX timestamps, and unrealistic peer delay
samples. Also protect the sync servo from large post-lock outliers so
invalid event timestamps do not enter the PI controller.
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
ctx->usb_rx_buf is a persistent member of the device context struct.
On error paths where the enqueue fails, the buffer was unreferenced
but the pointer was left dangling. Use net_buf_drop() to both
unreference and clear the pointer in one step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
ext2_verify_disk_superblock() did not validate that the on-disk fields
s_blocks_per_group and s_inodes_per_group are non-zero. Both are later
used as divisors during mount-time initialization:
- get_ngroups() in subsys/fs/ext2/ext2_diskops.c divides and modulos
s_blocks_count by s_blocks_per_group when ext2_fetch_block_group()
runs from ext2_init_fs().
- get_itable_entry() in the same file divides (ino - 1) by
s_inodes_per_group when fetching the root inode during mount.
Reject both fields up front in the superblock validator so the mount
fails with -EINVAL before any block-group or inode I/O occurs.
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
ts_to_ms() returns int64_t but the result was assigned to a uint32_t
variable without an explicit cast, relying on implicit narrowing.
Add an explicit (uint32_t) cast to document the intentional truncation
for relative timeouts, which are expected to be small values that fit
within uint32_t.
Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
timer_settime() with TIMER_ABSTIME computed the remaining duration by
subtracting k_timer_remaining_get(), which returns the time remaining
on the previous kernel timer, instead of the current value of the clock
associated with the timer as required by POSIX.
Fix this by storing the clockid from timer_create() in struct timer_obj
and using the existing timespec_to_timeoutms() helper in the TIMER_ABSTIME
path. That function reads the current clock via sys_clock_gettime() and
returns the correct relative duration, matching the pattern already used
by pthread_mutex_timedlock() and sem_timedwait() in this subsystem.
Fixes#107780
Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
Omitting the parameter name in a function definition is a C23 extension.
Fix this by naming second and third parameter in shell_thread function
definition to address compilation warning promoted to error in CI with
LLVM.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Up to now, some initialization has been deferred from the shell_init
function (which starts the shell_thread) to the shell_thread function. When
using SHELL_AUTOSTART this is fine, but when autostart is disabled this
causes a race between the shell_thread and whatever thread eventually calls
shell_start, because shell_start needs initialization to have completed
before it runs. So, move the remaining initialization code from the
beginning of the shell_thread to shell_init (before starting the
shell_thread).
Signed-off-by: Phil Hindman <phindman@xes-inc.com>
Allow the Wi-Fi certificate helper library to be used by Enterprise
credential users beyond the hostap/wpa_supplicant backend.
This lets offloaded Wi-Fi drivers load Enterprise TLS credentials through
the common Wi-Fi management path.
Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
z_impl_updatehub_probe() checks that the outer metadata object
array has exactly two elements, but then accesses objects[1].objects[0]
without checking that the inner array is non-empty. A server response
whose second object array is empty leaves that element zero-initialized,
so objects[1].objects[0].objects.sha256sum is NULL and the following
strlen() dereferences a NULL pointer, crashing the agent.
Reject metadata whose inner object array is empty before dereferencing
it, for both the 'any boards' and 'some boards' layouts.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
ctx.sock was set to 0 after cleanup, but 0 is a valid file
descriptor (stdin). If cleanup_connection() were called without an
open socket, zsock_close(0) would close stdin.
Guard the close with ctx.sock >= 0 and use -1 as the invalid
socket sentinel.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
coap_packet_init() was hardcoded to COAP_TYPE_CON, ignoring the
msgtype parameter. This meant report() calls passing COAP_TYPE_NON_CON
were silently sent as confirmable messages.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
strncmp with strlen(CONFIG_BOARD) only compares the first N
characters, allowing a supported_hardware entry like
"frdm_k64f_extra" to incorrectly match CONFIG_BOARD="frdm_k64f".
This could cause the device to accept firmware intended for a
different board variant.
Use strcmp for an exact match. Both strings are null-terminated.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
memcpy(metadata_copy, metadata, strlen(metadata)) does not copy the
null terminator. Since metadata_copy comes from k_malloc (unzeroed),
the subsequent strlen(metadata_copy) reads past the copied data into
uninitialized heap memory, and json_obj_parse may process garbage
data or crash.
Zero the buffer before copying to ensure proper null termination.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
strncmp(report.previous_state, "", sizeof("") - 1) always returns 0
because sizeof("") - 1 is 0, and strncmp with length 0 always
returns 0 per the C standard. This means report.error_message was
always set to "" and the server never received actual error details.
Replace with a direct check for a non-empty string. Guard the check
against a NULL previous_state, which state_name() can return for an
out-of-range state (the UPDATEHUB_FLASH_INIT_ERROR case passes a
response code instead of a state), so the new check does not
dereference a NULL pointer.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
When DTLS setsockopt or zsock_connect failed after socket creation,
the error path used ret to decide whether to call cleanup_connection().
However ret was set to -1 after socket creation, so the check
(ret > 0) was false and the socket was never closed.
Additionally, ret was set to 1 before socket creation, so if
zsock_socket itself failed, cleanup_connection() would be called
on an invalid file descriptor.
Replace the ret-based cleanup check with (ctx.sock >= 0) which
directly reflects whether a socket exists that needs closing.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
The UpdateHub subsystem has a race condition between the background
autohandler (system workqueue) and user-triggered operations (shell
commands or direct API calls). Both paths share the global ctx
structure without synchronization, allowing concurrent calls to
prepare_fds() which writes beyond the single-element ctx.fds[1]
array when ctx.nfds is already 1, corrupting adjacent memory
(ctx.sock) and leading to DoS or undefined behavior.
Replace the unused struct k_sem semaphore with a static K_MUTEX_DEFINE
to serialize access to the shared ctx across z_impl_updatehub_probe(),
z_impl_updatehub_update(), and z_impl_updatehub_report_error().
Add a bounds check to prepare_fds() (returning -ENOMEM when ctx.nfds
>= ARRAY_SIZE(ctx.fds)) as defense-in-depth against Out-of-Bounds
writes, and propagate the error through start_coap_client().
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Display which CPU each thread and interrupt stack is running on when
SMP is enabled. Shows CPU ID as the last column for clarity and proper
alignment. On non-SMP systems, output remains unchanged.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Client quic_connection_init() looked up endpoints by remote address
only. A stale client endpoint could be reused without being linked to
the new connection context's endpoints list, so TLS setsockopt returned
ENOTCONN. Orphaned endpoints also accumulated and could exhaust the small
endpoint pool, causing later tests to hang.
Always allocate a fresh client endpoint per connection context, release
any orphaned client endpoints for the same remote before allocation,
and close a leftover client connection fd in the HTTP/3 test before hook
when a prior test failed before after() ran.
Fixes intermittent failures in tests/net/lib/http_server/h3.
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>