The TinyCBOR library takes a `size_t *` length argument in many
functions which at function call contains the length of a buffer, and
at exit the actual size of the data. The FIDO-2 code however uses
`uint8_t` fields in `struct`s to store the data. Previously, a pointer
to that `uint8_t` filed was just casted to `size_t *`, resulting in
three neighboring bytes also being interpreted as being part of the
buffer size - which could result in undetected buffer overflows.
Similar, upon exit of the function not only the `uint8_t` sized length
`struct` member but also three neighboring bytes were written to.
I didn't care to investigate, but this really looks like crafted CBOR
payloads send to the FIDO2 implementation could result in arbitrary
code execution on the device.
By moving all the single byte struct elements to the end, we can reduce
padding inside `dose_t` and ensure that `recv_buf` is always aligned.
This saves some RAM:
master
------
text data bss dec hex filename
36384 136 12944 49464 c138 tests/driver_dose/bin/samr21-xpro/tests_driver_dose.e
this patch
----------
text data bss dec hex filename
36484 136 12936 49556 c194 tests/driver_dose/bin/samr21-xpro/tests_driver_dose.elf
In Asynchronous Fractional baud rate mode, the baud rate can not be
greater than the source frequency divided by the oversampling (8, 16).
Currently we are always using 16x oversampling.
This makes it impossible to e.g. set a 2 MHz UART baud rate on the 16 MHz
`saml10-xpro`.
With this change, the oversampling is automatically reduced to 8x which
allows us to set 16 MHz / 8 -> 2 MHz baud rate.
Align the first member of `struct sockaddr` and
`struct sockaddr_storage` as `uint32_t` to elevate the alignment of the
structure to level of `uint32_t`. This is needed as
`struct sockaddr_in` uses an `uint32_t` to store the IPv4 address,
previously resulting in `struct sockaddr_in` currently having a greater
alignment requirement that `struct sockaddr_storage`.
sys/ztimer: rework Kconfig
To eliminate circular dependencies based in periph_rtc and xtimer_ztimer_compatibility the following changes are applied:
- Change entrypoint of ztimer as a specific backend is always required
- Add a non-module symbol for ztimer_usec that bring in the ztimer and ztimer_usec module which allows the xtimer ztimer compatibility layer to only select the ztimer_usec module preventing circular dependency issues
This fixes the following warning on newer gcc/ld:
```
/usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
```
`WITHOUT_PEDANTIC(expr)` disables `-Wpedantic` for `expr`, but switches
back to the previous diagnostic settings afterwards. This helps defining
macros that are not strictly ISO compliant without having to drop the
`-Wpedantic` flag entirely.
`DECLARE_CONSTANT(identifier, const_expr)` declares an anonymous `enum`
constant named `identifier` and assigns it the value `const_expr`. Here,
`const_expr` has to be a compile time constant, but is not needed to be
an integer constant expression. It basically is a tool to magically
convert a non-integer constant expression into a integer constant
expression.
- Perform the same computation over and over again. If the results
differ, context switches have an impact on the calculation (e.g.
when the FPU internally uses more bits than a float, but that bits
are not saved / restored on context switch)
- Give the three threads the names "t1", "t2", and "t3" and print them
on console, instead of the process ID. This makes interpretation of
the output easier, as the process IDs depend e.g. on whether a given
platforms requires an idle thread or not.
- Do not use the thread ID in the calculation, but the number at the
end of the thread name. This will result in the number printed only
depending on the precision of the (software) FPU and the printf()
implementation, and not on which threads are created in which order
(including the idle thread)
- Add a script to support running `make test`
Update tests/thread_float/tests/01-run.py
Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>