Commit graph zephyr/subsys
Author SHA1 Message Date
Pisit Sawangvonganan
f24f2484d4 fs: fcb: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `subsys/fs/fcb`

Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-10-06 22:40:51 +02:00
Pisit Sawangvonganan
2648013fb7 debug: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `subsys/debug`

Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-10-06 22:40:51 +02:00
Pisit Sawangvonganan
29ec38a2e8 Bluetooth: MPL: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `subsys/bluetooth/audio`

Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-10-06 22:40:51 +02:00
Pisit Sawangvonganan
57954c80bc authentication: fido2: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `subsys/authentication/fido2`

Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-10-06 22:40:51 +02:00
Sylvio Alves
4b97fc46f3 bluetooth: host: fix lost deferred resolving list removals
When the resolving list cannot be changed, bt_id_del() defers the
removal by flagging the keys, but bt_keys_clear() wipes the keys
right after, so the removal is lost. The stale entry keeps
counting in rl_entries and can force the switch to host-side
resolution, after which no bonded peer using an RPA passes the
filter accept list. The removal has been lost this way since
commit e25d925242 ("Bluetooth: Defer RL update if there's an
ongoing connection").

Queue the peer identity address instead, so the removal survives
the keys being cleared or reused. bt_id_add() carries out the
queued removals before adding, so a peer added again after the
deferring condition ended is not removed afterwards, and
rebuilding the list after host-side resolution drops the queued
removals it no longer holds. The limited scan flag is dropped as
the removal is carried out right away in that case.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-10-06 10:04:59 +02:00
Robert Lubos
03182a8c23 tests: net: tcp: add a test for the RFC 6528 ISN hash
Connection setup skips the ISN calculation under CONFIG_NET_TEST, so no
network test exercises it. Expose the hash and the secret key with
ZTESTABLE_STATIC and add a test checking that the hash succeeds, is
stable for the same four-tuple and changes with the four-tuple and with
the key. Enable PSA SHA-256 in the test configuration so the hash is
compiled in.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-06 10:04:40 +02:00
Robert Lubos
b95d76889b net: tcp: keep the ISN clock from wrapping every 4 seconds
seq_scale() converts the uptime to nanoseconds as a 32 bit value before
shifting, so the clock term of the ISN wraps every 2^32 ns, about 4.3 s,
and only ever covers 26 bits. RFC 6528 expects the clock to keep
increasing so that the ISNs of successive connections on the same
four-tuple cannot overlap with sequence numbers still in flight.

Convert the uptime in 64 bits and shift before truncating, so the term
runs through the full 32 bits in 64 ns units and wraps every 275 s.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-06 10:04:40 +02:00
Robert Lubos
f98adb866f net: tcp: fix ISN hash output buffer size and check the PSA status
The RFC 6528 ISN code asks psa_hash_compute() for a SHA-256 digest into a
16 byte buffer, so the call fails with PSA_ERROR_BUFFER_TOO_SMALL and the
status is ignored. What ends up in the buffer depends on the PSA driver:
the TF-PSA-Crypto built-in driver fills it with '!', so the hash term is
the constant 0x21212121 and the ISN is just that plus the uptime, while
other drivers leave the buffer uninitialized. In both cases the ISN no
longer depends on the secret key or on the four-tuple, which defeats the
purpose of the option and makes the ISN easy to predict.

Size the buffer with PSA_HASH_LENGTH(), check the status and fall back to
sys_rand32_get() when the hash cannot be computed. Move the hash and the
address family dispatch into helpers so the fallback lives in one place.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-06 10:04:40 +02:00
Johan Hedberg
13f3fc65aa Bluetooth: Host: Fix the help text of BT_RX_STACK_SIZE
The help text calls the option the stack size of the receiving thread
and says that all callbacks to the application come from that thread.
Neither holds. Since commit 9ef7acd7d7 ("Bluetooth: Host: Add a
general purpose Bluetooth workqueue") the stack is that of the Bluetooth
workqueue, which also runs the deferred work of the Host, and the
documented callback contract promises no thread: some callbacks run in
the thread that calls the API which triggers them.

Say what the option sizes.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-06 10:03:39 +02:00
Aleksandr Khromykh
272d92d21d bluetooth: mesh: handle out-of-range First Index in Receivers Get
Clamp the entry count in handle_receivers_get() so a First Index past
the end of the receivers list yields a Receivers List with the list
field omitted, instead of a count computed from a negative difference,
as required by the Mesh DFU Model specification, section 6.2.3.5.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-06 07:29:33 +02:00
Benjamin Cabé
57f428032b hardening: net: add networking rules
Add hardening rules for keyed TCP initial sequence numbers, statically
compiled Wi-Fi credentials, and the networking test, packet capture and
benchmarking features.

- CONFIG_COAP_TEST_API_ENABLE: n (base)
- CONFIG_NET_CAPTURE: n (strict)
- CONFIG_NET_TCP_ISN_RFC6528: y (base)
- CONFIG_NET_ZPERF: n (strict)
- CONFIG_WIFI_CREDENTIALS_STATIC: n (base)

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-06 07:27:57 +02:00
Arkadiusz Grzelka
a709b6a5c6 Bluetooth: Host: keys: Fix re-adding IRKs on a repeated settings_load()
keys_commit() marks every bond with an IRK BT_KEYS_ID_PENDING_ADD on
each settings_load(), including one whose IRK is already in the
resolving list. The next advertising or scan start then calls
bt_id_add() for it again.

A Controller that rejects duplicates fails LE Add Device To Resolving
List with 0x12. With host address resolution, rl_entries counts the bond
twice.

Skip bonds that already have BT_KEYS_ID_ADDED set.

Fixes #120829

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-06 07:25:11 +02:00
Sylvio Alves
e8cf062c59 bluetooth: host: shell: fix build with iso sync receiver only
With BT_ISO_SYNC_RECEIVER enabled but no unicast role, the shell
failed to build: the big-sync command took its RX QoS from the
unicast iso_rx_qos, and connection_info compared against the
unicast iso_chan. Give the sync receiver its own RX QoS, since
the host only requires it to be non-NULL, compare against
iso_chan only when unicast is enabled, and declare iso_chan
under the same guard as its definition.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-10-06 07:22:49 +02:00
Pieter De Gendt
0b087eec4c net: ip: igmp: drop IGMPv3 queries with a truncated source list
A query was taken for IGMPv3 as soon as it had twelve octets, without
looking at its Number of Sources field. A query too short for the source
list it announces is malformed and was acted upon anyway.

Read the field and drop a query shorter than its source list. Octets
beyond the list are still accepted, as RFC 3376 ch 4.1.10 requires.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
34bbe2ad11 net: ip: igmp: ignore queries without the Router Alert option
All IGMP messages are sent with the IP Router Alert option (RFC 3376 ch
4), and a query that lacks it may have been forged from outside the
local network. Hosts should ignore IGMPv2 and IGMPv3 queries without the
option (RFC 3376 ch 9.1); IGMPv1 predates it.

Look for the option before acting on a query when the new
CONFIG_NET_IPV4_IGMP_REQUIRE_ROUTER_ALERT option is enabled. It is off
by default: some queriers, IGMP snooping switches among them, leave the
option out and their queries would go unanswered, which is the very
silence this series sets out to fix. The IPv4 option parser now reports
the Router Alert option to its callback.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
1cd469637f net: ip: igmp: measure the IGMP message over all buffers
The version of a query is derived from the length of the IGMP message,
which was computed from the first network buffer of the packet only. A
query with a long source list, or one received into small buffers, was
measured short.

Use the data remaining after the IPv4 header instead, which spans all
buffers of the packet.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
bf992fa07c net: ip: igmp: suppress reports already sent by another member
An IGMPv1 or IGMPv2 host that hears another member report a group while
its own timer for the group is running stops the timer and does not
report (RFC 2236 ch 3): the querier only needs one member per group.
Reports were consumed without looking at them.

Cancel the pending response and the pending retransmission of the group
when a v1 or v2 report for it arrives, unless the host operates in
IGMPv3 mode, which has no report suppression (RFC 3376 ch 7.2.2).

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
03802443a4 net: ip: igmp: retransmit the unsolicited report of a join
The report announcing a join was sent once. If it is lost, for example
because the switch port is still converging when the link comes up, the
group is not forwarded to the host until the next General Query is
answered, and never when no querier is present. RFC 3376 ch 5.1 requires
the State-Change Report to be retransmitted [Robustness Variable] - 1
times at random intervals within the Unsolicited Report Interval, and
RFC 2236 ch 3 recommends the same for IGMPv2.

Retransmit the report of a join and of a rejoin after interface up from
the IGMP timer, one second apart at most for IGMPv3 and ten seconds for
the older versions. The number of transmissions follows
CONFIG_NET_IPV4_IGMP_ROBUSTNESS. A leave is still reported once: the
group is gone from the interface when the report is sent, and a querier
that misses it keeps forwarding until its own timers expire. A further
change to a group while its report is being retransmitted starts over
with a report of the new state instead of merging the two as RFC 3376
ch 5.1 describes, which is equivalent as long as only filter mode
changes are reported.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
abe64f9214 net: ip: igmp: delay query responses by a random time
A Membership Query was answered immediately. A host must instead pick a
random delay bounded by the Max Resp Time of the query and answer when
it expires (RFC 3376 ch 5.2, RFC 2236 ch 3), so that the members of a
group do not all answer at once and a single report per group suffices.

Keep a response deadline per group and, for IGMPv3, one per interface
for General Queries, and drive them from one delayed work item. A new
query is merged with a pending response following the rules of RFC 3376
ch 5.2: a pending response to a General Query due sooner covers a new
query, and a group is answered at the earliest of its pending and the
newly selected delay. In IGMPv1 and IGMPv2 mode a General Query starts
an independent timer per group as required by RFC 2236; a repeated
Group-Specific Query then also takes the earlier of the two delays,
which answers no later than the reset rule of RFC 2236 would. The Max
Resp Code is decoded per version, including the exponential IGMPv3 form
and the fixed 10 seconds of an IGMPv1 query; the decoder is exported
within the stack for the tests.

A change of the compatibility mode cancels the pending responses. The
mode last applied is remembered per interface so that the change is
also detected when a querier present timer runs out, for which the
timer is armed as well.

Group-and-Source-Specific Queries are answered like Group-Specific ones,
with the full current state of the group.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
e69ae47ac3 net: ip: igmp: follow the version of older queriers on the network
An IGMPv3 host must operate in IGMPv1 or IGMPv2 compatibility mode when
a querier of that version is present, and an IGMPv2 host must fall back
to IGMPv1 (RFC 3376 ch 7.2.1, RFC 2236 ch 4). Only the query version was
looked at so far: a query was answered in its own version, while joins
and leaves were always sent in the newest version built in, which an
older querier does not understand.

Keep the IGMPv1 and IGMPv2 Querier Present timers per interface and
derive the Host Compatibility Mode from them. Reports for joins, rejoins
and query responses are sent in that version, a leave is a v3 change to
INCLUDE mode, a v2 Leave Group message or nothing at all for IGMPv1. No
leave is sent for the all-systems group, which never changes state (RFC
2236 ch 6). The timers run for the Older Version Querier Present
Timeout, computed from the new CONFIG_NET_IPV4_IGMP_ROBUSTNESS option;
without IGMPv3 built in the IGMPv1 timer runs for the Version 1 Router
Present Timeout of RFC 2236 instead.

The timers extend struct net_if_ipv4, so the net_if API version becomes
1.1.0.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
73a27b0047 net: ip: igmp: answer Group-Specific Queries
Every IGMP message that was not sent to 224.0.0.1 was dropped, which
covers Group-Specific Queries: a querier sends them to the group address
to check for remaining members after a Leave (RFC 2236 ch 3, RFC 3376
ch 4.1.12). A host that does not answer within the Last Member Query
Interval is pruned by the querier and by any IGMP snooping switch in
between, and stops receiving the group until the next General Query.

Answer a Group-Specific Query for a joined group with a report for that
group only. Only Membership Query messages are acted upon, other IGMP
messages sent to a joined group are consumed. The v2 and v3 send paths
are unified into one function per version.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
3aa9e6aa6d net: ip: igmp: report groups when rejoining after interface up
When an interface comes back up, its multicast groups are rejoined and a
membership report is sent for each. The IGMPv3 report was built while
the group was still marked as not joined, so it carried no group record
and the switch or router learned nothing. In both versions a report was
also sent for the all systems group 224.0.0.1, which is never reported.

Mark the group as joined before building the report, leave it again when
sending fails and skip the all systems group. The rejoin test now runs
for IGMPv3 as well and checks the contents of the report.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Pieter De Gendt
4189757509 net: ip: igmp: report current state in IGMPv3 query responses
A response to a Membership Query carries Current-State Records
(MODE_IS_INCLUDE or MODE_IS_EXCLUDE) per RFC 3376 ch 5.2, while a join
or leave sends a Filter-Mode-Change Record. The record type stored with
a joined group was the change record of the join, which is what was
sent back to every query.

Store the filter mode of the group instead and derive the change record
from it when a join or leave is reported. Query responses now carry the
filter mode itself.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-10-04 08:48:56 -05:00
Jean Nanchen
7d21b209b2 zbus: handle message buffer allocation failure
Return -ENOMEM when the message buffer allocation fails

Signed-off-by: Jean Nanchen <jean.nanchen@gmail.com>
2026-10-03 13:16:22 -05:00
Jukka Rissanen
c7bb91ec09 net: lib: sockets: can: Reject socket options on unbound socket
A CAN socket has no network interface until bind(), so its context
interface index is -1. In getsockopt() and setsockopt() for
NET_SOL_CAN_RAW, net_context_get_iface() then returns NULL,
net_if_get_device() returns NULL, and dev->api dereferences a NULL
pointer. Fail both sockopt calls with ENODEV while the socket is
not bound to a CAN interface.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-03 10:02:26 +02:00
Flavio Ceolin
6fe0093eb9 net: dns: reject answers whose RR type mismatches the query
dns_validate_msg() correlated the answer RR type with the query type only
for DNS_RESPONSE_IP, so a PTR answer to an A/AAAA query was accepted as a
synthesized NET_AF_LOCAL result whose name length is later used as an
address length and copied past sockaddr storage. Check every response
classification, still allowing CNAME for query redirection.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-10-03 09:57:14 +02:00
Benjamin Cabé
59d4e6639d authentication: fido2: declare strnlen() in clientpin
strnlen() is POSIX, not C17, so the host libc used by default on
native_sim does not declare it and fido2_clientpin.c fails to build.
Define _POSIX_C_SOURCE as other in-tree users of strnlen() do.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-02 22:11:34 -05:00
Sean Kyer
428e937217 cpu_freq: promote subsystem to unstable
Remove EXPERIMENTAL Kconfig and uprev version to
unstable 0.8.0

Signed-off-by: Sean Kyer <sean.actor@gmail.com>
2026-10-02 22:01:46 -05:00
Johan Hedberg
e51764c956 net: pkt: Fix double free corrupting the fragment header
Since commit 9bb2878319 ("net_buf: make reference counts atomic"),
net_pkt_frag_unref() decrements the fragment's ref_word itself, before
its double free check, instead of calling net_buf_unref(). At a zero
reference count the decrement borrows from the other bytes of ref_word:
from flags, and from pool_id if flags is zero, so a fragment that has
already been freed can end up with the wrong pool id.

Decrement with a compare-and-swap that leaves a zero count alone, also
when a double free races with the last unref.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-02 21:59:17 -05:00
Robert Lubos
1dbbc73739 net: l2: ieee802154: Reject unsupported 6LoWPAN fragment dispatch values
The fragment path accepts every dispatch in the 11xxxxxx range, but the
minimum header length check only applied to the exact FRAG1 and FRAGN
values. A fragment with any other dispatch in that range, such as
RFC 8025 paging or RFC 8931 RFRAG, and fewer bytes than a fragment
header therefore had its datagram size and tag parsed from bytes beyond
the fragment length and was added to the reassembly cache.

Drop anything other than FRAG1 and FRAGN, which are the only fragment
dispatch values implemented, and check the fragment length before
parsing the header.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-02 21:57:38 -05:00
Chaitanya Tata
8251a00d21 net: shell: ping: accept in-flight echo replies
The net ping command chose a new random ICMP identifier before every
echo request and counted replies only when the sequence matched the
latest probe. Valid replies were dropped when -i was shorter than RTT,
which showed up as 100% packet loss.

Use one identifier for the session, accept in-flight replies within a
64-probe window with atomic dedupe, and end the session on tail timeout
or when all sent probes are received (not when the last sequence reply
arrives first).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:Auto
2026-10-02 21:53:46 -05:00
harshit kudhial
f43f288094 posix: spinlock: fix trylock errno and invalidate handle on destroy
pthread_spin_trylock() forwards the return value of k_spin_trylock(),
which returns negative -EBUSY on contention instead of positive EBUSY
mandated by IEEE Std 1003.1 (POSIX). Convert negative return codes to
positive errno values.

In addition, pthread_spin_destroy() frees the pool bit in
posix_spinlock_bitarray but omits invalidating *lock, unlike other
POSIX options that set the destroyed handle to -1. An application
retaining a stale handle to a destroyed spinlock could subsequently
access or mutate a newly allocated spinlock if the same pool slot
is reallocated. Invalidate *lock by assigning (pthread_spinlock_t)-1.

Extend tests/subsys/portability/posix/spinlocks to verify that
destroyed spinlock handles are marked invalid and reject subsequent
operations with EINVAL even after pool slot reallocation.

Fixes #120412

Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
2026-10-02 17:48:33 -05:00
harshit kudhial
013fbfdbd0 posix: shm: fix fd leak on error paths and protect shm_list with mutex
In subsys/portability/posix/options/shm.c, shm_open() reserves a file
descriptor using zvfs_reserve_fd() before checking whether the target
shm object exists or is unlinked.

On error conditions where the shared memory object does not exist (when
O_CREAT is omitted) or where the object has already been unlinked,
shm_open() returned -1 with errno set to ENOENT or EACCES without
calling zvfs_free_fd(fd). This caused a permanent file descriptor leak
in the global ZVFS descriptor table (CONFIG_ZVFS_OPEN_MAX).

Additionally, the global doubly-linked list shm_list and object
reference counters were manipulated without synchronization across
concurrent shm_open(), shm_unlink(), and shm_close() calls.

Fix both issues by:
1. Releasing reserved file descriptors via zvfs_free_fd(fd) on all error
   return paths in shm_open().
2. Protecting shm_list traversal, insertion, removal, and reference
   counting with a dedicated mutex (shm_lock).
3. Adding a test in xsi_realtime verifying that repeated failed open
   attempts do not leak file descriptors.

Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
2026-10-02 17:38:40 -05:00
Flavio Ceolin
2fb3ee1760 modbus: raw: bound ADU length by the data buffer size
modbus_raw_rx_adu() accepted a length up to CONFIG_MODBUS_BUFFER_SIZE - 2
while struct modbus_adu.data holds CONFIG_MODBUS_BUFFER_SIZE - 4 bytes.
The FC15 and FC16 handlers index data[] by length and could read up to
two bytes past it, into the crc member of the same struct.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-10-02 10:38:35 -05:00
JP Hutchins
7385f5dfd2 mgmt: mcumgr: transport: smp_bt: Fix config details response
smp_bt_bridge_config_details() returned MGMT_RETURN_CHECK(ok) as its
bool result, which is false on success, and never set the return code.
transport_mgmt_config_details() therefore treated every successful
encode as a failure and returned its uninitialized rc as the SMP
result, leaving the configs list unterminated. The function also
reported the mode 0 configuration for any requested mode.

Set the return code and return the encode status, and reject modes
other than 0 with TRANSPORT_MGMT_ERR_INVALID_MODE, as the other
transports do.

Introduced in commit e095e47105 ("mgmt: mcumgr: transport: smp_bt:
Add support for transport mgmt").

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: JP Hutchins <jp@intercreate.io>
2026-10-02 08:42:07 -05:00
Jamie McCrae
d74c70bedd mgmt: mcumgr: transport: Fix Bluetooth MCUmgr client issues
Fixes some issues in the Bluetooth MCUmgr client code which did not
clean things up properly

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-10-02 08:42:07 -05:00
Jamie McCrae
1c243ae4d2 mgmt: mcumgr: transport: Fix Bluetooth info functions
Fixes some invalid values in the zcbor function calls

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-10-02 08:42:07 -05:00
Jamie McCrae
f19abacd71 mgmt: mcumgr: transport: Fix issue with Bluetooth MCUmgr client
Fixes an issue where builds would fail if transport management or
SMP client support were enabled in general because the MCUmgr
client code for Bluetooth could not be disabled, this adds a new
Kconfig to enable it ``CONFIG_MCUMGR_TRANSPORT_BT_CLIENT``

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-10-02 08:42:07 -05:00
Lezhi CHEN
75e0402aaa shell: do not print prompt/cmd-line while bypass is active
When a backend has shell_set_bypass() active, the transport is meant
to be fully owned by the bypass callback (e.g. a binary protocol
receiver, firmware upload, etc.). However, if the log backend for
that shell is still enabled, processing a log message unconditionally
erases the current line and reprints the shell prompt (and, if echo
is enabled, the in-progress command buffer):

- shell_log_process() (deferred log mode) took the non-readline
  branch whenever readline() wasn't active, which includes bypass
  mode, and called z_shell_print_prompt_and_cmd() there without
  checking ctx->bypass.
- process_log_msg() (immediate log mode and panic mode) took the same
  non-readline branch guarded only by z_flag_cmd_ctx_get(), which is
  false for the whole duration of bypass mode (it is only true while
  the command handler that called shell_set_bypass() is still
  running), so the same erase/prompt sequence was emitted there too.

shell_readline() itself refuses to run while bypass is active, so the
two are mutually exclusive; only the non-readline branches needed the
extra check.

This injects "uart:~$ " (and VT100 cursor/erase sequences, when
enabled) into whatever raw stream the bypass consumer expects,
corrupting it whenever a log message is emitted while bypass is
active.

shell_vfprintf(), used for ordinary shell_print()/shell_fprintf()
calls, already special-cases this with
`!z_flag_cmd_ctx_get(sh) && !sh->ctx->bypass`. Apply the same guard
to the two log-processing paths so prompt/cmd-line redraw is
suppressed for the duration of bypass mode, while still letting the
log message itself be written out.

Tested on native_sim with a minimal shell command that enters bypass
mode plus a background thread periodically logging: no prompt is
emitted between entering and leaving bypass mode. Also verified on
real hardware (nucleo_f091rc, CONFIG_SHELL_BACKEND_RTT), observed
over RTT.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Lezhi CHEN <lezhi.chen1998@outlook.com>
2026-10-02 08:33:59 -05:00
Johann Fischer
7f88f32154 usb: device_next: fix the possible null pointer dereferences
In the to-device callbacks implementation, explicitly check the wLength
value where a data stage is required. The host may submit a control
transfer without a data stage. In that case, the buf parameter will
always be NULL.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-10-01 17:03:58 -05:00
Sigmund Klåpbakken
9dbe9e8d48 canbus: isotp: use net_buf_skip()
net_buf_pull_mem() only pulls from the first buffer fragment. If the
len bytes span across two or more fragments, the buffer is left in an
invalid state.

Signed-off-by: Sigmund Klåpbakken <sigmundklaa@outlook.com>
2026-09-30 20:07:14 +02:00
Sigmund Klåpbakken
65b900592e canbus: isotp: use net_buf_linearize for net_buf
When using net_buf, get_send_ctx_data() would return the pointer to the
underlying memory. In cases where the buffer is discontiguous and the
current fragment is smaller than the requested length, the following
memcpy would access invalid memory when reading the last bytes. Since
the returned pointer is only used to perform a memcpy immediately
after, it can be moved inside get_send_ctx_data() instead, which allows
for using net_buf_linearize when using net_buf.

Signed-off-by: Sigmund Klåpbakken <sigmundklaa@outlook.com>
2026-09-30 20:07:14 +02:00
Dhruv Menon
1b8cab7ef6 net: zperf: treat a zero upload rate as unlimited
zperf_packet_duration() divided by the upload rate with no check, so a
shell command such as "zperf udp upload ... 0" faulted before any packet
was sent. A rate of 0 now means send as fast as possible, matching
iperf -b 0.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
Signed-off-by: Dhruv Menon <dhrumeno@qti.qualcomm.com>
2026-09-30 19:47:16 +02:00
Robert Lubos
da7b08af90 net: tcp: trim the right fragment when appending out of order data
When a new out of order segment overlaps the tail of the reassembly
queue, the overlap is computed from the last fragment of the queue but
removed from the head fragment. With two or more fragments queued the
head loses data it should keep, the chain gains a hole, check_seq_list()
rejects it and the whole queue is dropped.

Trim the overlap off the fragment it was computed from. The append path
is only taken when the new segment starts inside that fragment, so the
overlap is always shorter than the fragment.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-09-30 19:45:28 +02:00
Robert Lubos
8cfdf9ab91 net: tcp: handle an empty receive queue in the cleanup timer
When check_seq_list() rejects the out of order queue, the queue is
dropped but recv_queue_timer stays armed, either from this insert or
from an earlier one. tcp_cleanup_recv_queue() then runs with a NULL
queue and, with TCP debug logging enabled, tcp_get_seq() dereferences
it.

Cancel the timer when the queue is dropped, do not arm it for an empty
queue, and skip the cleanup when the queue is already gone. The last
covers the work item that is already running and waiting on the
connection lock while the queue is dropped.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-09-30 19:45:28 +02:00
Arkadiusz Grzelka
ca1694cc0f mgmt: mcumgr: zcbor_bulk: silence the UBSan function check
ZCBOR_MAP_DECODE_KEY_DECODER stores every decoder as a zcbor_decoder_t,
whose second parameter is void *, while the function behind the pointer
declares its own - struct zcbor_string * for zcbor_tstr_decode, for
instance. zcbor_map_decode_bulk() calls through the generic type, so
UBSan's function check reports every request that matches a key:

  zcbor_bulk.c:46:10: runtime error: call to function
  (unknown) through pointer to incorrect function type
  '_Bool (*)(zcbor_state_t *, void *)'

That fires on nearly every MCUmgr command, which masks whatever else a
sanitized or fuzzed build would have reported. The parameter is a
pointer either way, and issue #117167 settled on suppressing the check
rather than giving every decoder a wrapper, so the attribute goes on
the one function that makes the call. It is guarded on clang: GCC has
no function sanitizer and warns on the name.

Verified on native_sim/native/64 with host/llvm and CONFIG_UBSAN=y.
tests/subsys/mgmt/mcumgr/zcbor_bulk reports the error above without the
attribute and runs clean with it.

Fixes #117167

Assisted-by: Claude:claude-opus-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-09-30 19:44:52 +02:00
Andrey Dodonov
a51029cac7 net: http: server: send HTTP/1 final chunk with the last data
Append the terminating chunk to the final response's sendmsg() call
instead of sending it on its own, where Nagle's algorithm can hold it
back until the previous segment is acknowledged.

Test that a single-callback GET and POST response is sent in one call,
and that a response started before the request is complete is
terminated exactly once.

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2026-09-30 19:43:53 +02:00
Andrey Dodonov
8dd45218e8 net: http: server: coalesce HTTP/1 response writes
Build the header block in a buffer and send it together with the chunk
framing and data in one sendmsg() call, instead of one send() per
piece. Sockets without sendmsg() support fall back to send().

Add tests for headers longer than the header buffer and the gathered
send helper.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2026-09-30 19:43:53 +02:00
Andrey Dodonov
c92117d3d9 net: http: server: fix truncated HTTP/1 header names and Content-Type
Header names and the default Content-Type line were formatted into
a buffer of HTTP_RESPONSE_BUF_SIZE, which does not account for
CONFIG_HTTP_SERVER_MAX_CONTENT_TYPE_LENGTH. A longer name or Content-Type
was cut off together with its CRLF, corrupting the response. Send the
parts of each header line as they are, as already done for values.

Add tests for a long header name and a long Content-Type.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2026-09-30 19:43:53 +02:00
Aric Radzin
a1e8d6f97c mgmt: mcumgr: transport: Deprecate UART and shell MTU Kconfigs
CONFIG_MCUMGR_TRANSPORT_UART_MTU and CONFIG_MCUMGR_TRANSPORT_SHELL_MTU
only set the value returned by the get_mtu callbacks of the UART and
shell transports, which the SMP layer does not use. Serial frames are
limited to MCUMGR_SERIAL_MAX_FRAME (127) bytes and the reassembled
packet size is limited by CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE.

Deprecate them along with the callback. They keep their default and
keep working until removal, and emit a deprecation warning when changed
from the default (on a separate symbol, due to Kconfig limitations).

Also fix the UART_MCUMGR_RX_BUF_COUNT help text, which related the
buffer count to the UART MTU. Each receive buffer holds one line until
it is decoded into the packet buffer, so the count only limits how many
fragments can be queued.

Fixes #54106

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-09-30 19:42:14 +02:00