Skip to content

Fix union initialization in PSA operations for GCC 15 (test helpers) #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Feb 5, 2025

Test helpers and additional checks for the fix to Mbed-TLS/mbedtls#9814.

Continues #136. Will not pass the CI without some bug fixes from Mbed-TLS/mbedtls#9955.

PR checklist

  • TF-PSA-Crypto PR TODO
  • development PR TODO
  • 3.6 PR provided

For each multipart or interruptible operation, define an initializer
function that simulates the minimum that `my_op_t op = {0}` guarantees in C.
That is, initialize most fields to 0, but set the fields that are unions to
a nonzero value. This simulates platforms where initializing a union to
`{0}` only initializes the first member, and thus reading from another
member can yield a nonzero value. In our operation structures, the union's
first member is an unused `dummy`, and the other members are
driver-specific, so we just make the whole union nonzero and this has to be
good enough for the setup functions in the core to cope.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This fixes -Wmissing-field-initializers complaints from Clang <=3.x.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Fix the build against development.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
In every existing test driver entry point that is the setup for a multipart
operation, check that the driver operation structure is all-bits-zero on
entry, as guaranteed by the driver specification.

There is a risk that this isn't the case, mostly, on platforms where
initializing a union to `{0}` initializes only the default member and not
all members.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm force-pushed the union-initialization-gcc15-framework branch from bd33fb4 to 680e1b0 Compare February 7, 2025 08:52
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm
Copy link
Contributor Author

Superseded by #136 and #168 (same content, different commit history).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Development

Successfully merging this pull request may close these issues.

1 participant