Skip to content

Conversation

@keith-packard
Copy link
Contributor

The combination of the multi-byte loop with the single byte loop confuses GCC 14.3's array bounds checker. When the loop size is constant, check to see if it is a multiple of the multi-byte size and bail early. As this will be evaluated at compile time, there should be no run-time cost.

Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rather first make a PR in upstream Mbed TLS and then cherry pick it here?

@keith-packard
Copy link
Contributor Author

Could you rather first make a PR in upstream Mbed TLS and then cherry pick it here?

Mbed-TLS/mbedtls#10318

@tomi-font
Copy link
Collaborator

Mbed-TLS/mbedtls#10318

Thanks! If you want to get this merged here before it's merged upstream then please add a reference to the upstream PR (e.g. PR #) in the commit message. Otherwise we can just wait and cherry pick the upstream commit (with -x) once it's merged.

@keith-packard
Copy link
Contributor Author

Mbed-TLS/mbedtls#10318

Thanks! If you want to get this merged here before it's merged upstream then please add a reference to the upstream PR (e.g. PR #) in the commit message. Otherwise we can just wait and cherry pick the upstream commit (with -x) once it's merged.

It's blocking SDK version 0.18, so we should probably not wait (the fix is pretty easy to review in isolation).

@stephanosio
Copy link
Member

@d3zd3z @ceolin PTAL, this is currently blocking SDK 1.0 work.

Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe align this with Mbed-TLS/mbedtls#10318 and then we can merge this PR?

Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now missing the upstream PR # in the commit message 🙃

The combination of the multi-byte loop with the single byte loop
confuses GCC 14.3's array bounds checker. When the loop size is
constant, check to see if it is a multiple of the multi-byte size and
bail early. As this will be evaluated at compile time, there should be
no run-time cost.

This change uses the __builtin_constant_p compile-time operation. To
check if that is supported, the change uses the existing
MBEDTLS_HAS_BUILTIN macro. That macro was defined later in
library/common.h than is needed for this change, so it was moved up to
join some other macros that looked similar.

Upstream PR: Mbed-TLS/mbedtls#10318

Signed-off-by: Keith Packard <keithp@keithp.com>
@tomi-font tomi-font merged commit 2994b29 into zephyrproject-rtos:zephyr Oct 3, 2025
@keith-packard keith-packard deleted the gcc-14-3 branch October 10, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants