Commit graph zephyr/subsys
Author SHA1 Message Date
Jukka Rissanen
6911911fcf net: ieee802154: Accept -EALREADY from radio start and stop
The radio API documents -EALREADY from start() when the radio is
already up and from stop() when it is already down. The L2 treated
that as a failure in two places.

A scan starts the radio and fails on any other return value than 0,
so on an interface that is up, a scan fails with every driver that
follows the API. The scan also leaves the radio running, so after a
scan on an interface that is down, net_if_up() gets -EALREADY from
the L2 enable and fails, as net_if_up() and net_if_down() take every
negative value from the L2 as an error.

Treat -EALREADY as success in both places.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-22 18:19:47 +02:00
Phi Bang Nguyen
7303e006f5 ipc: ipc_service: rpmsg_lite: Fix the remote link-up check
rpmsg_lite_wait_for_link_up() returns RL_TRUE when the link is up and
RL_FALSE on timeout, but the remote path of open_instance() compared its
result against RL_SUCCESS, which is 0. A successful link-up was thus
reported as -ETIMEDOUT and the instance never opened on the remote core.

Fix it.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-22 18:19:06 +02:00
Johan Hedberg
81f280bed3 Bluetooth: Host: Fix completed packets for ACL data dropped early
With Controller to Host flow control, an ACL buffer that is freed before
hci_acl() has looked up its connection, as when the driver drops the
packet or it is too short for its header, keeps the zeroed user data of
its allocation. Its completion is then reported for handle 0x0000 while
the first connection is up: to a handle the Controller may not have, or
to another connection. Mark the buffer as having no connection from its
allocation on.

The host_disable test added here fails without the fix.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:17:35 +02:00
Sylvio Alves
bf9c810723 net: wifi: certs: wipe enterprise credentials before free
wifi_clear_enterprise_credentials() released the runtime copies
of the enterprise certificates and private keys with a plain
k_free(), leaving the key material in the freed heap blocks.

Zero each buffer with mbedtls_platform_zeroize() before freeing
it in a free_cert() helper, and use it in clear_cert_data() too,
so the file wipes keys in one place.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-10-22 18:17:21 +02:00
Johan Hedberg
e092d096e5 Bluetooth: Host: Fix TX state carried over to a new connection
A central keeps the object of a CIS for its next connection, and unlike
that of an ACL connection it is not zeroed in between. Two fields
survived a disconnection. next_is_frag, set while an SDU is sent in
part, made the first SDU of the next connection go out as the
continuation of one that the controller never got the start of. in_ll
kept counting the packets that the controller had not acknowledged,
which the TX scheduler takes for packets the controller still holds.

Reset both where the unacknowledged packets are returned.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:52 +02:00
Johan Hedberg
08ba2ad72a Bluetooth: ISO: Fix bt_disable() with data outstanding on a central CIS
bt_iso_reset() disconnected the CISes of a central by hand, without
touching the TX side of their connections. An SDU that the controller
had not acknowledged was never reported. With SDUs still queued in the
Host the connection outlived its CIG, and the connection cleanup then
disconnected the channel a second time, through a pointer that the CIG
cleanup had set to NULL.

Use bt_iso_chan_disconnected(), as for the BISes. It was avoided
because it removed the ISO data path, with an HCI command, which it no
longer does since
commit 065dca7e92 ("Bluetooth: ISO: Make setting ISO data explicit").

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:52 +02:00
Johan Hedberg
415a95cad2 Bluetooth: ISO: Fix SDUs dropped without send_failed on disconnection
bt_iso_chan_ops.send_failed is to be called for an SDU that
bt_iso_chan_send() accepted but that did not get sent because the
channel disconnected. The SDUs still queued in the Host at that point
were freed without it, and only those the controller had not
acknowledged were reported. An application that counts its SDUs in
flight never got the queued ones back.

Report them too, after those the controller had not acknowledged, and
only once the channel is disconnected, so that the callback cannot
queue them again. The callback's documentation no longer says that
nothing of such an SDU reached the controller: one that was not
acknowledged did, and a queued one may have in part.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:52 +02:00
Johan Hedberg
3608acee49 Bluetooth: ATT: Leave requests too large for a bearer to others
A bearer takes the first queued request that its channel option allows,
bt_att_chan_req_send() refuses it if it exceeds the ATT_MTU of the
bearer, and the request goes back to the head of the queue.
bt_att_create_pdu() accepts a request that fits any bearer, so one
restricted to EATT that fits only the UATT bearer, or one restricted to
UATT that fits only an EATT bearer, stalls every later request with the
same restriction without reporting an error.

Have a bearer skip the requests it cannot carry, and let the scan skip
a bearer only if its ATT_MTU is no larger than that of the previous one
of its kind. bt_att_sent() and bt_att_status(), which retry a request
on a bearer that was busy, now use the same selection instead of
taking the head of the queue.

The indication scenarios added to the eatt_notif bsim test in the next
commit fail without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:37 +02:00
Johan Hedberg
2c944a9f09 Bluetooth: ATT: Leave PDUs too large for an EATT bearer to others
A bearer takes the first queued PDU that its channel option allows. An
EATT bearer whose peer MTU is smaller than that PDU then fails to send
it, as L2CAP refuses the SDU with an error log, and puts it back at the
head of the queue, which keeps the bearer from sending anything else.
A PDU restricted to EATT that fits no EATT bearer, which
bt_att_create_pdu() accepts when the UATT bearer is large enough
(#119817), thereby stalls every later PDU restricted to EATT until an
EATT bearer's MTU grows.

Have an EATT bearer skip the PDUs that L2CAP would refuse, so that later
ones can use it meanwhile; a later PDU that may use either bearer kind
can then be sent before an earlier one waiting for the UATT bearer. A
bearer with nothing to send no longer implies the same for a following
bearer of its kind with a larger MTU, so the scan only skips those that
are not larger. The UATT bearer is unchanged.

The MTU scenario added to the eatt_notif bsim test in the next commit
fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:37 +02:00
Johan Hedberg
2315640795 Bluetooth: GATT: Take the host lock for the notification batches
A connection's pending notification batch is appended to and sent by
the notifying thread, sent by the flush work on the Bluetooth workqueue
and dropped by the disconnection cleanup, with no serialization. A
flush that preempts a notifying thread between its check of the batch
and the append leaves that thread appending through a NULL pointer or
to a buffer that is being sent. A batch whose allocation raced with the
disconnection cleanup is stored after it and never dropped, and the
flush work passes it to bt_att_send() with a NULL connection once the
connection object has been released.

Hold the host lock for every access. The ATT buffer allocation can
block and stays outside of it, so the connection state and a batch
started meanwhile by another thread are checked again before the new
batch is stored.

The races need preemption at specific points, which bsim does not
reproduce; the notify_multiple bsim scenarios pass.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:23 +02:00
Johan Hedberg
5a3453053c Bluetooth: GATT: Keep notification batches within the ATT_MTU
gatt_notify_mult() appends a notification to the pending batch as long
as the ATT buffer has room, but the buffers are sized for the local
ATT_MTU and the negotiated one can be smaller, for example when the
peer has not exchanged the ATT_MTU. The batch then exceeds the ATT_MTU:
an EATT bearer rejects such a PDU, so a batch restricted to EATT is
never sent. Flush the batch also when the next notification would take
it past the ATT_MTU.

The batch MTU scenario added to the GATT notify_multiple bsim test in
the next commit fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:23 +02:00
Johan Hedberg
2afb7444c0 Bluetooth: GATT: Count every value header in bt_gatt_notify_multiple()
bt_gatt_notify_multiple() compares the ATT_MTU with the total value
length plus a single handle and length header, leaving out the headers
of all other values. A PDU that exceeds the ATT_MTU by up to
4 * (num_params - 1) octets is accepted, and when the ATT_MTU is close
to the local maximum, appending the values overflows the ATT buffer.
Count the opcode and every header, so that the call fails with -ERANGE
as documented, and check the 16-bit limit after every value, as the
headers could otherwise make the sum wrap on 32-bit targets.

The MTU scenario added to the GATT notify_multiple bsim test in the
next commit fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:23 +02:00
Johan Hedberg
d0dd3f6c24 Bluetooth: GATT: Free a failed notification batch only once
bt_att_send() consumes the buffer also when it fails: it unrefs it when
the connection has no connected ATT bearer. gatt_notify_mult_send()
unrefs it again, so a notification batch flushed while the connection
is disconnecting frees its buffer twice, which the net_buf double free
assertion catches. Return the bt_att_send() result as its other callers
do.

The disconnect scenario added to the GATT notify_multiple bsim test in
the next commit fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:23 +02:00
Johann Fischer
969b037cab usb: device_next: bt_hci: clean up dangling HCI packet
A HCI packet allocated in the OUT path may remain dangling after the USB
device stack is disabled. The next USB enable call can perform a
race-free cleanup, as there will be no transfers coming back from the
drivers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johann Fischer
e554b42dfb usb: device_next: bt_hci: queue as many IN transfers as the pool allows
The semaphore limited the number of both possible IN transfers
to one at a time. This limitation is unnecessary. We can enqueue as many
buffers as are available in the pool, as long as packets are available
in the TX FIFO. Both ACL data and events still share the pool, but as
long as there are enough buffers, they do not block each other.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johann Fischer
7427ce6461 usb: device_next: bt_hci: queue as many OUT transfers as the pool allows
The BT_HCI_ACL_RX_ENGAGED flag limited the number of bulk OUT transfers
to one at a time. This limitation is unnecessary. Enqueuing all
available buffers improves throughput and simplifies transfer handling.
Also make number of buffer in the OUT pool configurable.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johann Fischer
d1231d66a9 usb: device_next: bt_hci: allow packet reassembly to recover
The OUT reassembly path had no way to recover from a transfer it refused.
When a chunk was rejected the transfer was dropped but the remaining
chunks of that HCI packet were still arriving and got parsed as new
HCI headers.

Track the remainder length of the HCI packet instead of comparing
against the expected length. Rename the variables to better reflect
their function. Skip new Bluetooth buffer allocation until new header.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johann Fischer
ead19ca881 usb: device_next: bt_hci: harden the RX path
In hci_pkt_get_len(), check the buffer length before using it to
calculate the packet length. Use size_t consistently to avoid uint16_t
overflow.

Dropt the OUT buffer on error and always reset the packet length.
Call hci_pkt_get_len() to get the packet length before Bluetooth packet
buffer is allocated.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johann Fischer
d525efe389 usb: device_next: bt_hci: prevent possible buffer leak in TX path
In TX thread, unref the buffer if the packet type is unsupported.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-22 18:15:48 +02:00
Johan Hedberg
c85c20c6d5 Bluetooth: Controller: Check the extended header length before parsing
The extended advertising parsers followed the fields that an extended
header's flags announce before confirming the header was long enough
to hold them, so a PDU whose flags announced more than its extended
header length held, or an extended header length larger than the PDU,
was parsed past its contents.

Confirm that the header fits the PDU and holds every field its flags
announce before walking it, and take nothing from the PDU otherwise,
in lll_scan_aux_setup(), both ull_scan_aux_setup() implementations and
the HCI report builders. An AUX_CHAIN_IND reaches these parsers
without going through the AUX_ADV_IND checks, so the check is in the
parsers rather than only in lll_scan_ext_tgta_check().

The periodic advertising report of such a PDU ends with the Incomplete
data status, as on a failed chain reception: the PDU can follow a
Partial report of its chain, which the Host would otherwise keep.

Valid PDUs are unaffected: a complete extended header, and a PDU
without one, pass the check.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 12:29:19 +02:00
Johan Hedberg
4e47e711d6 Bluetooth: Controller: Send no Incomplete periodic report while disabled
The Controller ends a periodic advertising report with the Incomplete
data status and no data when it fails to receive the rest of a chain,
or when the chain holds more data than CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX.
It sent that report also after the Host had disabled the reports of the
train (Core Spec Vol 4, Part E, Section 7.8.88), as the LLL receives
and follows the chains whether reporting is enabled or not, and only
the other reports checked it.

Send it only while reporting is enabled. The node that reports a failed
chain reception does not record whether reporting was enabled when the
PDUs were received, so the current state of the sync is checked.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 12:29:19 +02:00
Johan Hedberg
6872e86aa9 Bluetooth: Controller: Require the AdvA in scannable AUX_ADV_INDs
Connectable and scannable advertising has no AdvA in its ADV_EXT_IND
(Core Spec Vol 6, Part B, Table 2.4), so its AUX_ADV_IND has to have
one (Table 2.5). lll_scan_ext_tgta_check() did not require it in an
auxiliary PDU, so an active scanner sent an AUX_SCAN_REQ in answer to
an AUX_ADV_IND without AdvA, with other octets of the PDU as the AdvA.

Reject an auxiliary PDU of connectable or scannable advertising that
has no AdvA.

Tested with samples/bluetooth/observer (prj_extended.conf) on
nrf52_bsim against a BabbleSim playback device that sends such PDUs,
and with tests/bsim/bluetooth/ll/advx and
tests/bsim/bluetooth/host/adv on nrf52_bsim.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 12:29:19 +02:00
Jukka Rissanen
5e2eddb022 net: ethernet: bridge: Do not forward the reserved group addresses
A MAC Bridge never forwards a frame to one of the reserved addresses
01-80-C2-00-00-00 to 01-80-C2-00-00-0F (IEEE Std 802.1Q-2014 8.6.3,
Table 8-1). is_link_local_addr() masked the low nibble of the last
octet instead of the high one, so it matched 01-80-C2-00-00-00, -10,
-20 and so on. The bridge flooded frames to -01 to -0F, which carry
MAC Control, the slow protocols such as LACP, 802.1X EAPOL and LLDP,
to its other ports, and dropped frames to -10, which it should forward.

Test the high nibble, and check the address before the FDB lookup, so
that no FDB entry can forward such a frame either. The frame is now
passed on to the port it was received on, the same as gPTP frames
before: these protocols run per port. This also covers gPTP, whose
frames go to 01-80-C2-00-00-0E, so the later EtherType check stays
for gPTP frames to other addresses only.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-22 12:29:00 +02:00
Robert Lubos
a2ee04730b net: ip: Document the reassembly slot tradeoff in Kconfig
An incomplete fragmented datagram holds its reassembly slot until
NET_IPV{4,6}_FRAGMENT_TIMEOUT expires, and fragments of any other
datagram are dropped while no slot is free. With the default of one
slot a single stray or malicious fragment stops all fragmented traffic
for the whole timeout. This is the expected behaviour of a bounded
reassembly table on a memory constrained device, but the help texts
did not mention it. Spell it out and point at the two knobs that
change the tradeoff.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-22 12:28:48 +02:00
Jamie McCrae
9ab8a180ef mgmt: mcumgr: transport: bluetooth: Fix not returning transport error
Fixes 2 issues with transport management using bluetooth whereby a
connection attempt failed but no failure was returned, meaning that
clients would think the connection was actually successful

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2026-10-22 12:28:30 +02:00
Jamie McCrae
5e234f141c mgmt: mcumgr: transport: smp_bt: Fix le_coded set as required
Fixes this parameter wrongly being set as required, it is not a
required parameter and should only be set when attempting to
connect over LE coded PHY

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2026-10-22 12:28:30 +02:00
Jordan Yates
c3730fd44c modem: chat: cancel delayable work items in modem_chat_release
Cancel the `script_timeout_work` and `script_send_timeout_work` work
items in `modem_chat_release` and add a regression testcase.

Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-10-22 09:43:20 +02:00
Vinayak Kariappa Chettimada
4cd3fbf608 Bluetooth: Controller: Fix scan stop assertion
Fix assertion on scan stop waiting for semaphore that was
not given under race conditions wherein a scan event present
in the prepare pipeline did not abort, but remained in
continuous scanning.

ASSERTION FAIL [err == 0 || err == -114] @
  WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/ull_scan.c:657
	param1: 0 param2: 4294967285
@ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/ull_scan.c:657

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-10-22 09:41:47 +02:00
Vladislav Kulikov
592ea3668b usb: usb_c: pe: handle received Hard Reset in the Source role
A Hard Reset from the port partner always moved the Policy Engine to
the Sink recovery state. On a Source-only port that state is not
built, so the Hard Reset never completed and PD stayed dead until the
partner was unplugged. On a dual-role port attached as Source, the
Policy Engine ran the Sink states.

Use the Source Hard Reset Received state when the port is a Source.

Signed-off-by: Vladislav Kulikov <vlad_kulikov_c@pm.me>
2026-10-22 09:41:19 +02:00
Adrien Lessard
2dcd662649 pm: device_runtime: fix ISR-safe get rollback
When the device fails to resume, get_sync_locked() returns with the
power domain still claimed. Release it, as pm_device_runtime_get()
does for devices that are not ISR-safe.

Signed-off-by: Adrien Lessard <adrien.lessard@rbr-global.com>
2026-10-22 09:40:53 +02:00
Firas Sammoura
1185b04258 mgmt: ec_host_cmd: usb: keep the RX net_buf in a local variable
ctx->usb_rx_buf is only used between allocating an OUT buffer and
enqueuing it. Once enqueued, the buffer belongs to the USB stack and is
freed in the request callback, so the context never needs the pointer.

Use a local variable instead, and release the buffer with
net_buf_unref() if enqueuing fails: with no context pointer left,
there is nothing for net_buf_drop() to clear.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-22 09:40:31 +02:00
Philipp Steiner
a9b7b56af1 net: ptp: avoid servo reset loops during acquisition
During acquisition, offsets below the one-second hard-step threshold
can produce a PI rate request that the PHC cannot apply. Resetting the
servo leaves the phase offset unchanged, so the next Sync sample can
repeat the same rejected rate request indefinitely. The supported
correction depends on both the configurable PI gains and the driver;
100 ms is not the actual limit of this combination.

Keep the one-second step threshold and locked-state outlier filtering.
Use 100 ms as a proactive step threshold while unlocked. Also step
while unlocked when the PI output is unrepresentable or the requested
rate is rejected with -EINVAL, -ERANGE or -ENOTSUP. Return rate-adjust
status to the synchronization caller so locked rate failures and other
errors retain the conservative reset behavior without stepping.

Return clock-step status as well. If the rate-rejection fallback step
fails to read, calculate or set the time, reset the servo to discard the
rejected PI correction rather than accumulating it across failed
samples. Successful steps retain timestamp/delay invalidation and the
attempt to restore nominal rate.

The PTP clock API does not standardize range-error codes. Existing
range-checking drivers use -EINVAL, but a driver reporting rejection
as a generic error such as -EIO still resets and may repeat acquisition.
Do not treat arbitrary hardware errors as permission to step: a rate
failure does not imply that clock setting will also fail.

Extend regression coverage for rejected rates at positive and negative
50 ms offsets, lock-dependent recovery, hardware errors, failed
fallback steps and reacquisition. Track successfully applied PHC rates
separately from attempted rates to verify nominal-rate restoration.

Assisted-by: Oh-My-Pi:gpt-6.1-sol
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-10-22 09:39:17 +02:00
Sylvio Alves
da29f2545f llext: reject an out-of-section plt relocation
A PLT relocation whose offset lay outside its target section was
logged and skipped, so the extension loaded with that relocation
unapplied, while the regular relocation path rejects the same
offset. Fail the link instead. A type 0 (R_<arch>_NONE)
relocation writes nothing and Xtensa places one at the section
end, so it is still skipped.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-10-21 15:08:27 -05:00
Johan Hedberg
49502d57b1 Bluetooth: Controller: nordic: Fix preempted ECB use with EasyVDMA
A do_ecb() call preempted by an ISR that runs do_ecb() itself, such as
the radio ISR resolving a TargetA while a thread encrypts with
bt_encrypt_le(), relies on the preempting call clearing ECBDATAPTR to
start over. On SoCs with EasyVDMA (nRF54L, nRF54H20, nRF7120), the key
is in separate registers and ECBDATAPTR is IN.PTR, which is set after
the key:

- Preempted between its key writes, the call keeps the words that the
  preempting call wrote in place of its own earlier ones, then sets
  IN.PTR, and returns a result computed with a mix of both keys.
- Preempted after setting IN.PTR but before starting, it starts the
  ECB with IN.PTR cleared, which the nrf54l15bsim model reports as a
  hard fault on hardware.

Count the attempts, so that a call starts over whenever another one ran
in between, and have each call restore the pointers it found instead of
clearing them, so that a preempted call always starts with its own.

Tested with a scratch build that runs a nested ecb_encrypt() at each
point of do_ecb(), as a preempting ISR would: on nrf54l15bsim,
preemption during the key writes gave a wrong result and preemption
between the IN.PTR write and the start hit the model's NULL IN.PTR
error, and now every point gives the right result; on nrf52_bsim every
point gives the right result before and after. The bsim ll/conn,
ll/bis, ll/edtt, ll/multiple_id and ll/advx tests pass on both, and
host/security and host/privacy on nrf52_bsim. Not run on hardware.

Fixes #122777

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 15:02:24 -05:00
Johan Hedberg
f15830d16e Bluetooth: Controller: nordic: Don't let threads interleave in do_ecb()
do_ecb() relies on a call that preempts it completing before it
continues, as an ISR's does: the preempting call clears ECBDATAPTR when
done, and the preempted one then starts over. Threads of equal priority
can interleave instead, under time slicing, which is enabled by
default. One thread can then reprogram the ECB and clear ECBDATAPTR
while another one is still programming it, so that the other one starts
the ECB with ECBDATAPTR cleared, or on SoCs with EasyVDMA encrypts with
a mix of both keys.

Lock the scheduler while a thread runs do_ecb(), so that only ISRs can
preempt it, and their calls nest.

Fixes #122777

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 15:02:24 -05:00
Johan Hedberg
588ab4db8d Bluetooth: Controller: Fix RX thread stack sizes with NO_OPTIMIZATIONS
With CONFIG_NO_OPTIMIZATIONS=y, a combined Host and Controller build
overflows the Controller's priority RX thread stack (448 bytes) during
bt_enable(), and its RX thread needs more than its 896 bytes as well,
already before a connection. Both symbols are hidden, so they cannot
be set from a configuration file such as prj.conf.

Unoptimized peaks in samples/bluetooth/peripheral_hr on
nrf52dk/nrf52832 with pairing and notifications, optimized in
parentheses: priority RX thread 956 (312), RX thread 972 (304) bytes.
Default both to 2048 bytes with NO_OPTIMIZATIONS.

Tested on nrf52dk, unoptimized, MPU stack guard only, with the Host's
thread stacks and the main and system workqueue stacks raised:
peripheral_hr faults in the priority RX thread at boot without this
change and runs with it. Optimized .config files are unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 15:01:20 -05:00
Aleksandr Khromykh
378b6c2a30 bluetooth: mesh: reject BLOB Block Status with zero chunk size
handle_block_status() divides the current block size by the Chunk Size
field of the received BLOB Block Status without checking it. A Block
Status with Chunk Size 0 from a transfer target causes an integer
division by zero, which faults on cores that trap on it.

Chunk Size 0 is Prohibited (MshMBTv1.0 section 3.1.2.3), and a message
carrying a Prohibited value is not understood and shall be ignored
(MshPRT section 3.7.3.4). Reject such a message before computing the
chunk count. 0xFFFF (Chunk Size not set) is still accepted, as servers
send it in error responses.

Assisted-by: Copilot:claude-opus-5.5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-21 14:58:56 -05:00
Pieter De Gendt
46545d0d28 ipc: open-amp: keep the resource table size a multiple of 8
Linux copies the cached resource table into the loaded firmware with a
plain memcpy() in rproc_start(), even when the destination is mapped as
device memory. imx_rproc does that for the i.MX8MN/8MP TCM (ATT_IOMEM,
devm_ioremap()). The arm64 memcpy() finishes with 8 byte stores relative
to the end of the copy, so a table whose size isn't a multiple of 8
faults on an unaligned device memory access and panics the kernel.

This is a Linux issue, still present in mainline, but deployed kernels
have it. With CONFIG_RAM_CONSOLE the trace entry makes the table 140
bytes, which crashes the host on start for the i.MX8MP M7. Align the
table to 8 bytes, which rounds its size up. The padding is zeroed and
outside all entry offsets, so hosts ignore it, and tables that already
have a size that is a multiple of 8 are unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-21 14:57:18 -05:00
Firas Sammoura
a0b437a37f mgmt: ec_host_cmd: usb: track the pending event in atomic flags
pending_event is set by ec_host_cmd_backend_usb_trigger_event() in
the caller's thread and cleared from the USB stack thread once the
event notification is queued. Rename class_state to flags and track
the pending event as an atomic bit in it instead of a plain bool
shared between threads.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-21 14:56:30 -05:00
Jukka Rissanen
2328bd1438 net: quic: Reject STOP_SENDING frames for streams that cannot be stopped
RFC 9000 ch. 19.5 names two cases in which a STOP_SENDING frame is a
connection error of type STREAM_STATE_ERROR, and the handler checked
for neither:

- The frame is for a receive-only stream, that is a unidirectional
  stream opened by the peer. It was ignored when the stream was not
  known, and answered with a RESET_STREAM when it was.
- The frame is for a locally initiated stream that has not been
  created yet. It was ignored.

Close the connection in both cases. A stream that is not found can
also be one that was opened and is closed already, for which a late
STOP_SENDING is legitimate. Local stream IDs are handed out from one
counter per connection, so only an ID past everything opened so far is
taken as never created.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 14:55:38 -05:00
Jukka Rissanen
ca09c8075d net: quic: Bound the replies to STOP_SENDING frames
A STOP_SENDING frame is answered with a RESET_STREAM in a packet of
its own, and this happened for every such frame: the handler was left
out when the replies to one payload were capped, and it did not check
whether the stream had been reset already. A STOP_SENDING frame is
three bytes, so one datagram could make the device encrypt and send
several hundred packets.

The first STOP_SENDING for a stream has to be answered (RFC 9000
ch. 3.5), and a peer does not send the frame again once the packet
that carried it is acknowledged, so that reply cannot be put off. It
does not need a cap either: a stream is now reset only once, which
bounds these replies by the number of streams.

A frame for a stream that was reset already is a repeat from a peer
that did not get the RESET_STREAM. It is answered again, and those
replies are taken out of the per-payload reply budget.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 14:55:38 -05:00
Jukka Rissanen
cfd1a8e4f5 net: quic: Let only an Initial packet start a connection
When a long header packet matched no known connection, the server
created an endpoint for it whatever its type. The checks that guard
the start of a connection, the address validation token or Retry and
the 1200 byte minimum datagram size, are applied to Initial packets
only. A small Handshake or 0-RTT packet from any address therefore got
an endpoint of its own, and enough of them could keep the endpoint
table occupied.

Drop long header packets other than Initial that belong to no known
connection, as RFC 9000 ch. 5.2.2 describes. The RFC allows a server
to buffer early 0-RTT packets instead; that is not done here, and a
client sends such data again after the handshake.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 14:55:38 -05:00
Jukka Rissanen
eaff6b706b net: quic: Match the endpoint when looking up a stream
quic_find_stream() took the endpoint as an argument but matched a
stream by its ID and context only. A stream ID is unique within one
connection, not within a context: until a connection is handed over to
its own context at the end of the handshake, its streams are kept in
the listening context together with those of every other connection
at the same stage.

Such streams can exist when 0-RTT data is accepted. With two
handshakes in progress, a STREAM frame from one peer was then
delivered to the stream that the other peer had opened with the same
ID, mixing the early data of two clients.

Require the stream to belong to the endpoint the frame arrived on.
The function becomes ZTESTABLE_STATIC so that a test can call it.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-21 14:55:38 -05:00
Benjamin Cabé
6da3c78890 net: utils: honor the caller's buffer size in net_addr_ntop() verifier
The net_addr_ntop() syscall verifier formatted into its full-size local
buffer and ignored the caller's size, so undersized destination buffers
succeeded (truncated) from user mode where kernel mode fails. Clamp the
format width to the caller's size so both modes agree.

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 15:04:18 +02:00
Johan Hedberg
f6525ff3f7 Bluetooth: Controller: Report LE Encrypt only with BT_CTLR_CRYPTO
Since commit a66baa1101 ("Bluetooth: Controller: Introduce
BT_CTLR_CRYPTO_SUPPORT") the HCI LE Encrypt command is handled only
with BT_CTLR_CRYPTO, but Read Local Supported Commands reports it in
every build. With BT_CTLR_CRYPTO=n, a Host that relies on the report
gets Unknown HCI Command.

Set the LE Encrypt bit only with BT_CTLR_CRYPTO.

Tested: on nrf52_bsim, Read Local Supported Commands reports LE Encrypt
with the default configuration and not with BT_CTLR_CRYPTO=n, and LE
Rand with both.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 13:46:41 +02:00
Johan Hedberg
2e62ddf65e Bluetooth: Controller: Fix builds with BT_CTLR_CRYPTO disabled
BT_CTLR_CRYPTO selects whether the Controller provides bt_rand(),
bt_encrypt_le() and HCI LE Encrypt, and with them the ECB driver that
the Zephyr Link Layer also needs for LE encryption and privacy. Its
LLLs indicate support for both features whenever the Controller has
crypto support at all, so a build with BT_CTLR_CRYPTO=n still enables
them:

- LE encryption derives the session key with ecb_encrypt(), which the
  Nordic LLL builds only with BT_CTLR_CRYPTO since commit a66baa1101
  ("Bluetooth: Controller: Introduce BT_CTLR_CRYPTO_SUPPORT"), so every
  such build with BT_CTLR_LE_ENC fails to link. On rv32m1_vega, the
  board enables the CAU3 driver that it uses only with BT_CTLR_CRYPTO.
- Privacy calls bt_rand() and bt_encrypt_le() through rpa.c, which are
  then the Host's: from the radio ISR, and from HCI command handling,
  where with BT_HOST_CRYPTO_PRNG=n bt_rand() sends HCI LE Rand from
  within the command being handled and deadlocks. HCI-only builds have
  no bt_rand() at all and stop at configuration time, as
  BT_CTLR_PRIVACY selects BT_RPA, which depends on BT_HOST_CRYPTO or
  BT_CTLR_CRYPTO.

Have the Nordic and OpenISA LLLs indicate support for LE encryption and
privacy only with BT_CTLR_CRYPTO, and say so in its help text.

Tested with BT_CTLR_CRYPTO=n: samples/bluetooth/peripheral builds on
nrf52840dk/nrf52840, nrf51dk/nrf51822, nrf54l15dk/nrf54l15/cpuapp and
nrf52_bsim, samples/bluetooth/central on nrf52840dk/nrf52840, hci_ipc on
nrf5340dk/nrf5340/cpunet, hci_uart on nrf52840dk/nrf52840, and
tests/bluetooth/init with prj_ctlr_central_priv.conf on
rv32m1_vega/openisa_rv32m1/ri5cy. The default configurations of these
builds are unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 13:46:41 +02:00
Paulo Santos
d4a50db799 usb: device_next: bound the CDC NCM/ECM TX wait on a slot token
Turn sync_sem into a TX slot token that send() claims with a bounded
wait, dropping the packet when the previous bulk IN transfer still holds
it. The bulk IN completion unrefs the buffer and returns the token.

Signed-off-by: Paulo Santos <pauloxrms@gmail.com>
Assisted-by: Claude:claude-opus-5
2026-10-21 13:44:07 +02:00
Johan Hedberg
c79ea22c31 Bluetooth: Remove unreachable Controller crypto calls from rpa.c
rpa.c calls lll_csrand_get() and ecb_encrypt() directly when both
BT_CTLR_CRYPTO and BT_HOST_CRYPTO are enabled. That combination cannot
link, as both crypto implementations define bt_rand() and
bt_encrypt_le(), and Kconfig now rejects it, so the branch is dead.
With privacy enabled it does not compile either, as rpa.c does not
include lll.h.

Call bt_rand() and bt_encrypt_le() unconditionally, which is what
every configuration that links has done since commit a66baa1101
("Bluetooth: Controller: Introduce BT_CTLR_CRYPTO_SUPPORT").

Tested: the EAD samples on nrf52840dk/nrf52840 and
samples/bluetooth/peripheral with BT_CTLR_CRYPTO=n and BT_CTLR_LE_ENC=n
build; the bsim host/privacy and host/adv/encrypted tests pass.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 12:02:48 +02:00
Johan Hedberg
817f941024 Bluetooth: Host: Make BT_HOST_CRYPTO depend on !BT_CTLR_CRYPTO
In a combined build, host/crypto_psa.c and controller/crypto/crypto.c
both define bt_rand(), bt_encrypt_le() and bt_encrypt_be(), so
BT_HOST_CRYPTO=y together with BT_CTLR_CRYPTO=y fails to link with
multiple definitions. The option only had a conditional default, which
left the combination open to be set by hand.

Make the dependency explicit, so that Kconfig rejects the combination
with a warning. No configuration that links changes value.

Tested: samples/bluetooth/beacon on nrf52840dk/nrf52840 with
-DCONFIG_BT_HOST_CRYPTO=y gives a Kconfig warning and links.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 12:02:48 +02:00
Vinayak Kariappa Chettimada
1cfd5c0952 Bluetooth: Controller: Fix incorrect aux_offset used when scanning
Fix incorrect aux_offset used when Extended Scanning using
the single timer implementation of tIFS software switching.

The Radio END timestamp was not captured and hence the
packet timing was not accumulated. Passive scanning on the
primary channel reception for single timer implementation
did not config the DPPI that was used for Timer Clear and
Radio END capture.

The bug was present when LLL scheduling was used for
auxiliary PDU reception, where the auxiliary PDU followed
closely after the primary channel PDU.

Relates to commit ebc023b0ce ("Bluetooth: Controller: Fix
incorrect aux offset using single timer").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-10-21 12:01:00 +02:00