Commit graph zephyr/subsys
Author SHA1 Message Date
Johan Hedberg
f3fb71df0b Bluetooth: Fix default thread stack sizes on arm64
The default stack sizes of the Bluetooth threads are too small on arm64.
With CONFIG_STACK_SENTINEL=y, tests/bluetooth/host_disable overflows the
stacks of bt_tx_processor (1188 bytes used, default 1024) and BT LW WQ
(1540 used, default 1400 with BT_ECC) on qemu_cortex_a53, and BT RX WQ
uses 1028 of its 1200.

arch/arm64/core/Kconfig raises the kernel's stack defaults to 4096 on
arm64, the system workqueue's among them. Give the TX processor, the
Bluetooth workqueue and the long workqueue the same default. It comes
first in each list (for the long workqueue after NO_OPTIMIZATIONS, also
4096), so on arm64 it takes precedence over the feature-dependent values
that follow, and the other architectures keep theirs.

Tested on qemu_cortex_a53 with the stack sentinel and the thread
analyzer: no Bluetooth thread overflows in any scenario of the test.

Fixes #122573

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:59:59 +02:00
Johan Hedberg
8cab85f0d4 Bluetooth: Fix the copyright holder of files from Silicon Labs
These files were written for Silicon Laboratories, which holds their
copyright, but were added with the line for The Zephyr Project
Contributors. They came with #119615, #120846, #121257 and #122021, and
nobody has changed them since. The build and test scaffolding that came
with them, and a file mostly copied from another test, keep that line.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:56:53 +02:00
Johan Hedberg
04b3be4813 Bluetooth: Host: Fix build for SoCs without soc.h
hci_core.c includes <soc.h>, so the Host does not build for a SoC that
has none, such as qemu_cortex_a53. Nothing in the file uses the header
since commit aaeff3c165
("Bluetooth: Add basic host-side support for HCI vendor extensions")
replaced the nRF5x FICR read it came with. Remove the include.

Built for qemu_cortex_a53, which fails without this change, and for
ESP32, Silabs, NXP, STM32WB, nRF and qemu_x86 targets.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:55:10 +02:00
Tom Johnson
0bdc6b4238 net: if: take the TX timestamp reference before queueing
net_if_add_tx_timestamp() puts the packet on tx_ts_queue and only then
takes the reference the timestamp thread drops after running the
callbacks. That thread is cooperative, so when the caller has a lower
priority, the k_fifo_put() wakes it and it runs at once: it calls the
timestamp callbacks and unrefs the packet before the caller has taken
its reference, freeing a packet the sender still uses.

Seen with the PTP stack on an STM32H7RS (eth_stm32_hal calls
net_if_add_tx_timestamp() from its TX completion, in the sending
thread) with the PTP thread at a low preemptible priority: an MPU
fault in ethernet_send() reading the freed packet's Ethernet header,
seconds after PTP starts.

Take the reference before queueing the packet.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Tom Johnson <wiltshiretom@icloud.com>
2026-10-21 11:53:53 +02:00
Johan Hedberg
40275ef7af Bluetooth: Classic: AVRCP: Fix TG vendor response queue corruption
bt_avrcp_tg_vendor_tx_work() hands a single-packet response to
bt_avctp_send() while the buffer is still the head of
tg->vd_rsp_tx_pending, and removes it from that list only afterwards.
By then bt_avctp_send() has linked the same buf->node into the AVCTP TX
list, so with another response pending the removal leaves the list
with a tail but no head: the responses queued behind it and every
vendor dependent response the TG sends later are never sent, and their
buffers are lost.

Remove the buffer from the pending list before handing it to AVCTP.

Tested with a Bumble CT against the BR shell on native_sim over the
simulated BR/EDR controllers: with two CHANGED notifications queued
behind a fragmented GetElementAttributes response, only the first one
arrived and no later response did; with the fix all of them arrive.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:53:14 +02:00
Johan Hedberg
407aad9483 Bluetooth: L2CAP: Fix TX stall behind a channel without credits
When the channel that the TX processor pulls from has no credits for a
new K-frame, the channel is taken off the ready list and the pull
returns nothing, without triggering the processor again as the other
empty paths of the pull do. Another channel of the connection with data
to send then waits for a completion, credits or new data, which may
never come, for instance when the peer waits for that data before it
gives credits.

Trigger the TX processor again, so that it pulls from the next channel.

Tested with a unit test that queues a signalling response behind an SDU
on a channel without credits: without this change the response is not
sent.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:52:48 +02:00
Benjamin Cabé
d8d6a521a9 net: ftp: use net_socklen_t for the address length
new_ftp_connection() declares its address length as socklen_t, which
is only defined by net_compat.h when CONFIG_NET_NAMESPACE_COMPAT_MODE
is enabled. With the compatibility mode disabled the FTP client fails
to build. Use net_socklen_t, which is always defined.

Co-authored-by: Chris Friedt <chris@fr4.co>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-21 11:51:30 +02:00
Benjamin Cabé
6b050e8a3c net: sntp: zero-initialize the server's peer address storage
net_sad() takes a const net_sockaddr_storage pointer, so GCC assumes
the callee reads the object. sntp_server.c passes an uninitialized
local that is filled in through the cast-away pointer, and unoptimized
coverage builds (-O0 -fprofile-arcs) fail with
-Werror=maybe-uninitialized ("by argument 1 of type const
struct net_sockaddr_storage * to net_sad"). Zero-initialize the
local.

Co-authored-by: Chris Friedt <chris@fr4.co>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-21 11:51:30 +02:00
Benjamin Cabé
526657a458 net: sockets: do not log a NULL thread name on invalid socket access
Guard the NULL thread name in get_sock_vtable()'s invalid-access
NET_DBG. k_thread_name_get() returns NULL when CONFIG_THREAD_NAME=n,
and the deferred-logging cbprintf string packaging strlen()s the %s
argument, so an invalid socket access (e.g. recvfrom() on a stale fd)
crashes with a NULL dereference. Pass a "?" placeholder instead.

Co-authored-by: Chris Friedt <chris@fr4.co>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-21 11:50:05 +02:00
Tom Burdick
9e881bb0b3 rtio: executor: take completion flags from the sqe being completed
rtio_executor_handle_oneshot() builds a completion per transaction
member but took the flags from the entry the iodev completed instead of
the member being completed. The flags carry the mempool block index, so
a transaction whose read is not its first member loses that read, and
one whose read is first has every member claim the same blocks.

Compute the flags from curr. Adds test coverage verifying the correct
behavior.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
2026-10-21 11:49:26 +02:00
Tom Burdick
4a2bf4fb6a rtio: executor: Directly resubmit multishot
The context submission queue is an mpsc (rtio.sq). It takes one
consumer, and that is rtio_executor_submit() on the submitting thread.
Resubmitting multishot submissions pushed them back on that queue and
called the executor again from the iodev completion, usually an interrupt.
That interrupt would then consume the submission queue, and dispatch
submissions to the relevant io devices. This meant there were multiple
consumers of the lock free mpsc queue which could have lead to
inconsist state from the race.

Submit the entry straight back to its iodev, a mpsc queue typically.
A multishot is never chained or in a transaction, so it is already
linked the way the executor would leave it and no API promises have been
broken in doing so.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
2026-10-21 11:49:26 +02:00
Tom Burdick
15da895c55 rtio: executor: drop mempool flags from a terminated multishot CQE
When a multishot submission is canceled or fails, the executor releases
the mempool blocks it read into but still submits a completion encoding
them. A consumer gets back memory that is already in the pool and
releases it a second time.

Clear the completion flags on that path, so the completion reports no
buffer and rtio_cqe_get_mempool_buffer() returns -EINVAL.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
2026-10-21 11:49:26 +02:00
Jukka Rissanen
61f53b9608 net: dns: Route absolute .local and single-label names correctly
An absolute name ends with a dot that stands for the root label, so
"host.local." and "host.local" are the same name, as are "host." and
"host". The resolver compared the text after the last dot with ".local"
and treated a name as single-label only when it had no dot at all, so
"host.local." was sent to the unicast DNS servers with a random id and
"host." was never sent over LLMNR.

RFC 6762 ch. 3 requires any query for a name ending with ".local." to be
sent to the mDNS multicast address, and RFC 4795 ch. 3 uses LLMNR for
single-label names. Ignore one trailing dot when classifying a query,
and use the same check where the query id is set to zero for mDNS.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:45:13 +02:00
Jukka Rissanen
8d30e5d0a7 net: ethernet: bridge: Accept a NULL interface in FDB deletion
The API documentation of eth_bridge_fdb_del() and
eth_bridge_fdb_del_iface() says that a NULL interface deletes from any
interface, but both functions returned -EINVAL for it.

Implement the documented behavior: eth_bridge_fdb_del() with a NULL
interface removes every entry of the address, which matters for a
multicast address with entries on several ports, and
eth_bridge_fdb_del_iface() with a NULL interface empties the table.
With an interface given, nothing changes. No in-tree caller passes
NULL today.

Extend the bridge test with the NULL cases; with the previous code
both calls fail with -EINVAL and leave the entries in place.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:44:59 +02:00
Johan Hedberg
68a2e85099 Bluetooth: Host: Fix advertising sent callback on connection
bt_le_ext_adv_cb.sent is documented to report that an advertising set
reached its timeout or event limit. It was also called, right after
the connected callback, when a connection ended a set that had been
started with a limit, which an application could only take for a
timeout.

Call it only when the status of the LE Advertising Set Terminated
event is not success. Core Specification 6.3, Vol 4, Part E, 7.7.65.18
defines success as a connection having been created and every other
status as advertising having ended for another reason. Bluetooth Mesh,
the one in-tree user acting on the callback, passes its PB-GATT bsim
tests, which end limited sets with a connection.

Fixes #121951

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:44:08 +02:00
Jukka Rissanen
9a0ab5a839 net: quic: Make quic_send_packet() visible to tests
A test needs to send at a given encryption level without going
through a whole handshake. Make the function ZTESTABLE_STATIC, like
the other internals the test suite calls directly.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
3a028fd142 doc: net: quic: Describe the PSA key slot needs
The number of PSA key slots is fixed at build time and its default is
too small for more than one QUIC connection, but nothing told the user
how many slots an endpoint takes.

Add sizing guidance to the QUIC documentation and point to it from the
help text of CONFIG_QUIC_MAX_ENDPOINTS. The steady state figures were
measured with the two connection test on native_sim; the handshake and
key update peaks are taken from the code.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
b69f0b17a3 net: quic: Name PSA key slot exhaustion in the log
When no PSA key slot is free, setting up the packet protection keys
fails with a chain of generic errors, and the failed import in the
HKDF step was only logged at debug level. The cause, a slot count that
is too small for the number of connections, could not be told from
the log.

Report a failed key import in one place and say so when the reason is
a missing key slot.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
9d3eef9a29 net: quic: Restart the idle timer of the endpoint a packet is for
process_short_header() refreshed the idle timer of the endpoint that
owns the UDP socket instead of the endpoint the 1-RTT packet was
addressed to. A server shares one socket between all of its
connections, so the timer of a server side connection was only ever
refreshed by long header packets, that is during the handshake. Such
a connection was closed when the negotiated idle timeout expired even
though it was carrying traffic, and the peer's following packets were
dropped as belonging to an unknown connection.

Restart the timer of the endpoint found by the connection ID lookup,
and do it once the packet has been decrypted: RFC 9000 ch. 10.1
restarts the timer for a packet that is "received and processed
successfully". Doing it on receipt would let a packet that fails
authentication keep a connection from timing out. The long header
path restarted the timer on receipt too and is changed the same way.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
069737f6a2 net: quic: Discard the Initial keys once Handshake packets are in use
The Initial packet protection keys were kept until the endpoint was
torn down, which held four PSA key slots per endpoint and left the
unauthenticated Initial level open for the lifetime of the connection.

RFC 9001 ch. 4.9.1 requires a client to discard the Initial keys when
it first sends a Handshake packet, and a server when it first
successfully processes one. Do both. The loss recovery state of the
Initial packets is discarded at the same time (RFC 9002 ch. 6.4), not
only at the end of the handshake.

The places that set up the Initial keys on demand now leave a
discarded level alone, and late Initial packets are dropped before
decryption. A request to send at a discarded level, Initial or
Handshake, is ignored: before, it was reported as an invalid key for
the Initial level and queued for a later attempt for the Handshake
level.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
93b2df9947 net: quic: Discard the Handshake keys when the handshake is confirmed
The Handshake packet protection keys were kept until the endpoint was
torn down, although only the Handshake packet number space was
abandoned on confirmation. Each endpoint therefore held four PSA key
slots it could no longer make use of.

RFC 9001 ch. 4.9.2 requires an endpoint to discard its Handshake keys
when the handshake is confirmed. Do that on the server when it has
completed the handshake and on the client when HANDSHAKE_DONE arrives.

RFC 9002 ch. 6.4 requires the loss recovery state of the packets sent
with discarded keys to be discarded too. One function now does both,
and both places that handle HANDSHAKE_DONE use it; before, only one
of them abandoned the packet number space.

The discard is remembered in the crypto context. A Handshake packet
that arrives afterwards is dropped before decryption; without this it
would fail to decrypt and take the established endpoint down with it.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
7c692477bb net: quic: Release the ECDHE key after the key agreement
The ephemeral ECDHE private key was kept until the TLS context was
freed, so every endpoint held one PSA key slot for the whole lifetime
of its connection for a key that is used exactly once.

Destroy the key as soon as the shared secret has been computed. The
public key is exported when the key pair is generated, so nothing
refers to the key afterwards.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jukka Rissanen
e58e860ecf net: quic: Fail the handshake when traffic keys cannot be installed
The TLS code ignored the result of the secret callback for the
Handshake and Application levels. When the QUIC layer could not set up
the packet protection keys, for example because no PSA key slot was
free, the handshake carried on without them: the server kept deferring
its Handshake flight and the connection only ended when the probe
timeouts were exhausted, about 15 seconds later.

Return the callback result, as is already done for the Early level.
The error is -EIO, which the CRYPTO frame error handling turns into a
CONNECTION_CLOSE with an internal error, so both peers see the failure
at once.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 11:42:26 +02:00
Jordan Yates
d3317090e0 modem: chat: fix modem_chat_run_script race condition
Fix a race condition around the modem chat object being released before
the synchronous wait semaphore and result are given. Allocate the result
and semaphore in the sync caller and cache the pointers before releasing
the object.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-10-21 11:41:31 +02:00
Ryan Erickson
89718936cc net: l2: wifi: certs: fix credential length pointer type
struct wifi_cert_data stores pointers to the credential length fields
of struct wifi_enterprise_creds_params, which are uint32_t, but
declares the pointer as size_t *. On 64-bit targets this fails to
build with GCC 14 (-Wincompatible-pointer-types), and the 8-byte store
through the pointer in process_certificates() would overwrite the
neighbouring field.

Use uint32_t * to match the fields it points to. The size_t length
returned by tls_credential_get() is narrowed on assignment, which is
safe because credential sizes are bounded by available heap.

Fixes #122481

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: GitHub Copilot:claude-opus-5.5
Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2026-10-20 12:15:26 -05:00
Ryan Erickson
ab31a66b79 net: lib: tls_credentials: shell: fix size_t handling on 64-bit
tls_cred_cmd_get() passes the address of an int to base64_encode(),
whose olen parameter is a size_t pointer. On 64-bit targets size_t is
wider than int, so this fails to build with GCC 14
(-Wincompatible-pointer-types) and would otherwise let base64_encode()
write past the end of the int.

Declare the output length as size_t, and print cred_written (a size_t)
with %zu instead of %d to fix the related -Wformat warnings.

Fixes #122480

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: GitHub Copilot:claude-opus-5.5
Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2026-10-20 12:15:10 -05:00
Flavio Ceolin
80b3aa02a1 canbus: isotp: check tailroom of next fragment on receive
receive_add_mem() splits consecutive frame data between the active
fragment and the next one, but did not check that the remainder fits
into the next fragment. net_buf_add_mem() only asserts on tailroom, so
an oversized append wrote past the fragment data when assertions are
disabled. On the missing fragment error path, process_cf() also kept
going and could move the context out of the error state once the
remaining length reached zero.

Check the tailroom of the next fragment, return an error from
receive_add_mem() and stop processing the frame in process_cf() when
the data does not fit.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-10-20 17:45:12 +02:00
Flavio Ceolin
a07880fee6 canbus: isotp: validate consecutive frame data length
process_cf() read the address extension and PCI bytes without checking
that the frame carries them. For a frame with fewer bytes than the
header, can_dl - index is negative and converts to a large unsigned
value in the comparison against the remaining length, so the CF length
check passed and the full remaining message length was appended from a
frame with no payload, writing past the receive buffers.

Ignore frames too short to hold the address extension, report
ISOTP_N_ERROR for frames without a PCI byte, and reject consecutive
frames whose CAN_DL exceeds the one set by the first frame. ISO 15765-2
only allows the last consecutive frame to be shorter, and the per-block
buffer allocation relies on the first frame CAN_DL.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-10-20 17:45:12 +02:00
Mike J. Chen
fa3708dee6 mem_mgmt: mem_attr_heap: Add initialization asserts
Add asserts to catch cases where the mem_attr_heap is used
before being initialized.

Signed-off-by: Mike J. Chen <mjchen@google.com>
Co-authored-by: Dawid Olszewski <dolszewski@antmicro.com>
Signed-off-by: Dawid Olszewski <dolszewski@antmicro.com>
2026-10-20 17:44:54 +02:00
Jukka Rissanen
eed8b6e494 net: ethernet: bridge: Free a frame that no port sends
bridge_iface_send_process() frees the original packet only when it sent
clones. When no other port could take the frame, because the ports were
down, the original was neither sent nor freed and the packet leaked.
The same happened when the first clone failed with more than one port
to send to. A forwarded frame is cloned from the RX pool, so every such
frame took one RX packet for good.

Free the original when no port takes it, and always after sending
clones. Pick the ports to send to in one pass and send to exactly
those, so that a port going down between the count and the send cannot
make the bridge send the original packet twice.

The bridge test checks that a frame received while the other ports are
down leaves the RX pool as it was. It also releases what an earlier
test left in the fake driver, which the following FDB test relied on.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-20 17:40:20 +02:00
Jukka Rissanen
de5eff8c63 net: dns: Enforce the label and name limits when packing a QNAME
dns_msg_pack_qname() copied each label into the buffer without checking
its length. A label of 64 octets or more got a length octet with one of
the two high bits set, which a receiver reads as a compression pointer
or a reserved label type, and an empty label ("a..b", ".a", "a..")
became a zero octet that ends the name early. The total length was
bounded only by the caller's buffer.

RFC 1035 ch. 3.1 limits a label to 63 octets and a name, counting the
length octets and the terminating zero, to 255 octets. The root name
"." is the only one with an empty label. Return -EINVAL for names that
break these rules, before the buffer size is considered, so an over-long
name fails the same way whatever buffer the caller passes.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-20 17:39:48 +02:00
Flavio Ceolin
fb6b996d28 Bluetooth: Mesh: Check state before handling BLOB Block Status
handle_block_status() looks up the sender in the transfer target list
before checking the client state. The target list is reached through
cli->inputs, which is only set once a procedure is started, so a Block
Status received by a client that never started one dereferences a NULL
pointer.

Ignore Block Status messages unless the client is in one of the block
states, as rx_block_status() already requires, and make target_get()
return NULL when no inputs are set.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-10-20 17:37:08 +02:00
Jordan Yates
dc4a55f1fd net: dns: fix QNAME encoding for trailing dot
Treat a trailing dot as the DNS root label when encoding a QNAME. Avoid
emitting an additional zero-length label, which shifts the encoded QTYPE
and QCLASS fields.

Add a regression test confirming that absolute and relative forms of the
same domain produce identical DNS query packets.

Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-10-20 17:35:07 +02:00
Firas Sammoura
4c65bd0476 mgmt: ec_host_cmd: usb: dequeue endpoints in a loop on reset
ec_host_cmd_reset() dequeues the OUT, bulk IN and interrupt IN
endpoints with three copies of the same call and error check. Loop
over the endpoint addresses instead. The error message now identifies
the endpoint by its address, as the request callback already does.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-20 17:33:45 +02:00
Jukka Rissanen
cbf223bd88 net: ethernet: Do not count an unknown EtherType as a processing error
A frame with a valid EtherType that no handler is registered for was
counted twice. The Ethernet L2 counted it as unknown_protocol and
returned NET_DROP, and process_data() counts every NET_DROP from the L2
as a processing error of the interface. On a device with IPv4 disabled,
every ARP, DHCP or IPv4 multicast frame from its peers then raised
processing_error on a healthy link and hid real faults in it.

Consume such a frame in the L2 instead: unref it and return NET_OK, as
the L3 handlers do with a frame they take. It is then counted only as
unknown_protocol, which commit ce49beb297 ("net: ethernet: Fixes for
ethernet stats reporting.") added for these frames. Frames forwarded
with CONFIG_NET_ETHERNET_FORWARD_UNRECOGNISED_ETHERTYPE are unchanged.

The doc of processing_error now says where these frames are counted.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-20 17:32:06 +02:00
Martin Stumpf
2077a57973 mgmt: mcumgr: grp: os_mgmt: fix stack_unused type
k_thread_stack_space_get() takes a size_t pointer, but stack_unused was
declared as unsigned int. On 64-bit targets such as native_sim/64 these
types differ in size, triggering -Wincompatible-pointer-types and
letting the kernel write 8 bytes into a 4-byte variable.

Declare stack_unused as size_t to match the API.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-20 17:31:49 +02:00
Johan Hedberg
7d3ec35414 Bluetooth: Host: Fix NULL write when limited advertising ends
With CONFIG_BT_RPA_SHARING, adv_rpa_expired() records in an array that
an advertising set wants to keep its RPA, so that le_rpa_invalidate()
rotates the RPA of an identity for all of its sets or for none. When
limited advertising is stopped or times out, bt_id_adv_limited_stopped()
passes no array, and an rpa_expired callback that returns false made
the Host write through a NULL pointer.

The end of limited advertising rotates no shared RPA, so there is
nothing to record then.

Introduced by commit 6ce38c1aa7 ("bluetooth: id: fix adv sets with
same id use different RPA"), first released in v3.7.0.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-20 17:30:34 +02:00
Johan Hedberg
5a8cae9c71 Bluetooth: Host: Add quirk for adv timeout without terminated event
The timeout of high duty cycle connectable directed advertising that was
enabled with the extended advertising commands may be reported with a
connection complete event instead of, or in addition to, the LE
Advertising Set Terminated event (Core Specification 6.3, Vol 4, Part E,
7.8.56). The Host acts on the terminated event only. With a Controller
that sends the connection complete alone the advertising set stays
enabled, the application gets no connected callback with
BT_HCI_ERR_ADV_TIMEOUT, and every further start returns -EALREADY.

Acting on the connection complete in general is not safe. With a
Controller that sends both events, the terminated event would end
whatever the application started in between, and the connection complete
does not name the advertising set. Add
BT_HCI_QUIRK_NO_ADV_TERM_ON_DIR_TIMEOUT for Controllers known to send
the connection complete alone. With it the Host ends the enabled high
duty cycle directed advertising set at that event, through the code that
handles the terminated event, and refuses to start a second such set
while one is enabled. A terminated event for such a set shows that the
quirk is wrong for the Controller, and the Host warns about it. The
quirk is read from devicetree at build time, so builds without it are
unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-20 17:29:34 +02:00
Josuah Demangeon
18b120d1ad video: ctrls: improve logging
Add more error messages to avoid control to fail silently without clues
about what is happening.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-10-20 17:26:57 +02:00
Arkadiusz Grzelka
9bb3553b74 Bluetooth: BAP: BSNK: Report decrypting state after BIG resync
When the BIG sync is lost or terminated for any reason other than a MIC
failure, the BIG_Encryption field of the receive state is set to
Not_Encrypted, but the sink keeps its BIG encrypted flag. The BIGInfo
handler only updates the receive state when that flag changes, and the
BIG synced handler only changed Broadcast_Code_Required and Bad_Code to
Decrypting. A sink that synced to the same encrypted BIG again thus
reported Not_Encrypted while decrypting the BIG.

Set the BIG_Encryption field to Decrypting on BIG sync whenever the BIG
was synced with encryption.

Extend the broadcast_sink_encrypted bsim test to stop and sync the sink
again, and verify that the receive state reports Decrypting after both
syncs.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-20 17:25:27 +02:00
chao an
3161e877c8 Bluetooth: BAP: Reset client buffer on send failures
Reset the unicast client ATT buffer when control point PDU preparation
or write submission fails before the GATT layer can consume it.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
ae5d31703d Bluetooth: AVRCP: Free buffers on send failure
Release locally allocated vendor PDUs when sending them fails so the
failed AVRCP command path does not leak buffers. Avoid an extra unref in
send_single_vendor_rsp() so the response path does not release the
buffer twice after send failure cleanup.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
2a4c0f32d4 Bluetooth: Classic: HFP: Free command buffer on format failure
Release the RFCOMM command buffer when formatting the HFP HF command
fails so the allocated buffer is not leaked on the error path.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
b6de45bbdb Bluetooth: AVRCP: Unregister SDP records on failure
Roll back AVRCP controller and target SDP records if the later AVCTP
server registration fails so failed role registration leaves no record.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
b4072a8dce Bluetooth: RFCOMM: Use safe iteration when dropping DLCs
Use safe list iteration when starting pending DLCs because the failure
path drops the current DLC and removes it from the session list.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
294c91ff95 Bluetooth: PBAP: Unregister SDP record on PSE failure
Roll back the PBAP PSE SDP record when OBEX server registration fails
so that a failed registration does not leave a stale service record.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
52dcc3764f Bluetooth: CSIP: Reset instance on register failure
Clear the generated service state if GATT service registration fails so
that the instance can be selected again by a later registration attempt.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
a63dc1070e Bluetooth: Classic: L2CAP: Remove channels before delete
Remove BR/EDR L2CAP channels from the connection list before deleting
them during disconnection so stale list entries are not left behind.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
5bd3a24034 Bluetooth: L2CAP: Remove channels from connection list
Remove each L2CAP channel from the connection list before deleting it
during disconnection so that stale list entries are not left behind.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00
chao an
eab427e94d Bluetooth: ATT: Free context on channel allocation failure
Release the ATT context when the fixed channel cannot be allocated so
that the slab entry is not leaked on the error path.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-10-19 16:33:21 +02:00