Enabling CONFIG_XOSHIRO_RANDOM_GENERATOR when
CONFIG_ENTROPY_NEEDS_POST_PROCESSING is set, we can support entropy
drivers which are not able to provide large amount of data.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
The functions that add DNS records (PTR, SRV, TXT, AAAA, A) all use a
buf_size argument which represents the size of the whole buffer, not the
remaining size. The higher function that calls these did not provide the
correct argument: it passed the remaining size in the buffer.
Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
Stop scheduling bt_id_add() as workqueue work during settings load.
Mark keys BT_KEYS_ID_PENDING_ADD only, then flush them synchronously
in start_scan(), adv_start_legacy()/bt_le_ext_adv_start(),
bt_conn_le_create and bt_conn_le_create_auto when
BT_DEV_ID_PENDING is set.
We don't necessarily need to update resolving list in controller
unless actively start using it, also eliminates a race where a
workqueue-issued bt_id_add() blocks on HCI while bt_keys_clear()
concurrently zeroes the same key slot.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
The DHCPv4 client logs the received address with NET_INFO when an
address is successfully obtained from the server. The DHCPv6 client
had no equivalent log message, making it difficult to confirm that
DHCPv6 address assignment succeeded.
Add a NET_INFO log when a DHCPv6 address is successfully configured,
consistent with the DHCPv4 client behavior.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
In setup_ipv6(), the net management event callback registration was
placed after the early exit for empty CONFIG_NET_CONFIG_MY_IPV6_ADDR.
This means that in DHCPv6-only configurations (no static IPv6 address),
the callback was never registered, and the IPv6 address and lifetime
were never printed when DHCPv6 obtained an address.
This is inconsistent with setup_ipv4(), which correctly registers the
callback before the empty address check, allowing DHCPv4 address
events to be handled even without a static IPv4 address.
Move the event callback registration and router flag check before the
empty address goto, and always include NET_EVENT_IPV6_ADDR_ADD in the
event mask so that DHCPv6 address additions are always captured.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
In net_context_get(), contexts[i].local is memset to zero before
find_available_port() is called. This leaves sa_family as 0, which
causes check_used_port() to skip both the IPv6 (sa_family ==
NET_AF_INET6) and IPv4 (sa_family == NET_AF_INET) collision-detection
branches, unconditionally returning "port available".
When the PRNG produces the same random port for two consecutive
socket() calls, the collision is not detected and both contexts are
assigned the same ephemeral port. The duplicate is only caught later
during listen() → net_conn_register(), which finds the identical
connection handler and returns -EADDRINUSE (errno 112).
Fix by setting sin6_family / sin_family on the local address
immediately after the memset and before find_available_port() is
called, so that check_used_port() enters the correct address-family
branch and properly detects port collisions.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
The exthdr_len was previously validated against the total
packet length, which did not account for the header's offset.
This could allow a crafted packet to cause an out-of-bounds
read by claiming a length that exceeds the remaining buffer.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106331
This commit:
1. Validates exthdr_len against (pkt_len - start_offset).
2. Adds strict bounds checking for sub-options (PADN/others)
to ensure they do not exceed the extension header boundary.
3. Validates the return value of net_pkt_skip().
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
On PD capable SRC detach, DPM was not being notified of
POWER_CHANGE_0A0 or NOT_PD_CONNECTED. Fix by notifying
POWER_CHANGE_0A0 in tc_attached_snk_exit() and NOT_PD_CONNECTED in
pe_suspend_entry().
On PD capable SNK or SRC detach, pe_suspend_entry() did not clear
the explicit contract flag. Fix by clearing PE_FLAGS_EXPLICIT_CONTRACT
in pe_suspend_entry().
On PD capable SNK attach, DPM was not being notified of PD_CONNECTED
at the correct time. Fix by notifying PD_CONNECTED when PS_RDY is
successfully transmitted (source) or received (sink), using
atomic_test_and_set_bit() to prevent duplicate notifications during
renegotiations.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
validate the assumptions about buffers returned by alloc_buf() in the
LE CoC receive path.
if the returned buffer does not provide enough user_data space for the
internal segment counter, disconnect and drop the buffer instead of
reading or writing past the metadata area.
also document that alloc_buf() must return a buffer with at least
sizeof(uint16_t) bytes of user_data.
Signed-off-by: Oleh Konko <security@1seal.org>
By making `MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` depend on that neither
`CTR_DRBG_CSPRNG_GENERATOR` nor `PSA_CSPRNG_GENERATOR` is enabled so if
they are we automatically fall back to `MBEDTLS_PSA_CRYPTO_LEGACY_RNG`.
This combination is problematic because we get in a scenario where
`psa_generate_random()` => `get_random_data()` => `sys_csrand_get()` =>
`psa_generate_random()`.
Resolves#105626.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Add an internal cache buffer in Intel's
adsp mtrace backend to mitigate log overwrite
issue when slot window is full.
Signed-off-by: Jun Lai <jun.lai@dolby.com>
Fixes an unused function warning when compiling with llvm, looks like
that does not fire with gcc for inline functions but it does for llvm,
tested with:
west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/cdc_acm --
-DTOOLCHAIN_VARIANT_COMPILER=llvm -DCONFIG_UART_LINE_CTRL=n
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fixes:
zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:635:19:
warning: unused function 'hid_dev_set_out_polling' [-Wunused-function]
zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:665:19:
warning: unused function 'hid_dev_set_in_polling' [-Wunused-function]
When compiling with LLVM:
west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/hid-keyboard --
-DTOOLCHAIN_VARIANT_COMPILER=llvm
Functions are only used when CONFIG_USBD_HID_SET_POLLING_PERIOD is
enabled, set as __maybe_unused instaed of inline.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Power managed devices should be able to return -EBUSY at
pm_action() (driver) calls without generating error log messages.
Suppress such error messages to allow the driver to decide at
sleep time if it still is unable to suspend, without generating
log noise.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
UVC counts frame intervals as 100ns units, so to get a number in
nanosecond, the value from USB needs to be divided by either
(USEC_PER_SEC * 10) or (NSEC_PER_SEC / 100). A mix of the two
was used.
Signed-off-by: Josuah Demangeon <me@josuah.net>
When UVC is part of a multi-function device, baInterfaceNr(0) may point
to an incorrect interface number. Assign the actual streaming interface
number after the configuration descriptor is initialized.
This is follow-up on commit 8d7bb597fc
("usb: uvc: use uvc_device_ in API and add _enable()/_shutdown()").
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This is more prone to breaking than simply inheriting all include
directories from the tfpsacrypto library.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
When logging statically configured network SSID, use the Kconfig string
instead of a SSID buffer where it was copied to, as the latter is not
guarantee to be NULL terminated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case CONFIG_WIFI_CREDENTIALS_STATIC is used, verify the statically
configured SSID/password lengths to guarantee they don't exceed the
allowed SSID and password character limits and thus overflow credential
buffers.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
do net_if_set_link_addr() for
NET_REQUEST_ETHERNET_SET_MAC_ADDRESS
in ethernet_set_config(), that way drivers don't have
to do it themself.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Writable string entries in ocpp_cfg_info are free'd if non NULL in
ocpp_set_cfg_val(). Thus they should not be statically allocated.
Initialise with NULL instead.
CFG_SUPPORTED_FEATURE_PROFILE is not writable and should be fine.
Signed-off-by: Markus Becker <markushx@gmail.com>
BootNotification did not transport Serial Number and other information,
because the NULL check is wrong.
Signed-off-by: Markus Becker <markushx@gmail.com>
use zephyr ring buffer and also read and write more
than one char at a time.
Also use events to notify new rx or tx.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
CONFIG_CONSOLE_GETCHAR doesn't need
`CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS`
and `CONFIG_CONSOLE_HANDLER` since a long time.
So don't select it unnessesaryly.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
A struct net_sockaddr should be considered an incomplete type, replace by
using net_sockaddr_storage.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
If `attr` or `attr->user_data` is NULL, then the include
characteristic is invalid. However the function,
bt_gatt_attr_read_included, should not return an errno value, but
a GATT error. The reason why errno cannot be used, is that the
return value is parsed through err_to_att which would make
-EINVAL become 0x16 (depending on the libc implementation),
which is an invalid ATT error code.
This was incorrectly introduced by commit
5a8189bf2a.
Changed the return value from errno to a proper GATT/ATT error.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When providing a addr in net_if_set_link_addr() it should be
constant, as this function should not change the address
in the pointer.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Update the HW models module to:
63ccab2988bf4c144b3cd324a0277e03206fa413
Including the following:
63ccab2 RADIO: Adjust Tx rampup timings
72d7680 RADIO: Correct note
AND
Adjust Bluetooth controller radio hal timings to match this new timings.
AND
Change the random seed in a very long test which is relatively sensitive
to timing, and fails due to this rampup timing change.
Repeat of note from 63ccab2:
--
IMPORTANT!: This commit changes the timing of the radio model, and
therefore requires controller SW to adjust its constants accordingly.
Even after such an adjustment it is likely some tests timing will change
marginally (if for example some advertisement event anchoring is done
as soon as possible by the controller or the like), and therefore that
some tests execution will change, and that too time sensitive test may
fail.
--
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Increase the maximum allowed repeat count for read and write/erase
test commands from 10 to 10000. This allows for more accurate
measurements over longer test durations.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add a way to add private key, peer endpoint and keepalive
when setting up the wireguard connection using the shell.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make blake2s private so that it cannot be used (easily) by other parts
of Zephyr codespace. The blake2s is part of the code until PSA will
have support for it. At that point the code will be removed and
replaced by the PSA calls.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Instead of using buffers for keys, use PSA key management to
store the keys. This is more safe than handling buffers in
the code directly.
Do some cleanup of the code structure and make the functions
in wg_psa.c static to disallow use outside of Wireguard.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If running wg in native-sim, use the host clock to get the
current time. This helps to have a proper handshake when
connecting even after restarting the zephyr.exe process.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to provide a function that will need to get
the current time from a RTC or SNTP or similar.
Wireguard handshake replay prevention needs a monotonic
time so the application should get it from somewhere.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Send peer add/del network event when the peers is either added
to the system or deleted from the system.
Send VPN connected / disconnected event when a VPN connection
is successfully established or the peer connection is disconnected.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The "net wg show 1" will show detailed information of the peer
id 1. This is useful when debugging connectivity issues.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The crypto code is taken from wireguard-lwip project at
https://github.com/smartalock/wireguard-lwip
and is BSD-3-Clause licensed code.
The Blake2 RFC 7693 and XChaCha20 (from
https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha-03)
cannot currently use PSA APIs.
The XChaCha20 is found in PSA 1.2 but Zephyr is not yet using that
version.
All the other crypto usage is converted to use PSA APIs.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>