Skip to content
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

Backport 2.28: Fix builds with MBEDTLS_HAVE_TIME disabled and test #5563

Merged
merged 16 commits into from
Mar 15, 2022

Conversation

AndrzejKurek
Copy link
Contributor

@AndrzejKurek AndrzejKurek commented Feb 22, 2022

Backport of #3624.
Fix builds that use time.h without MBEDTLS_HAVE_TIME.
Changes compared to the original:

  • programs/fuzz/common.h using config.h directly instead of build_info.h;
  • programs/test/query_config.c uploaded.

@AndrzejKurek AndrzejKurek added bug enhancement mbed TLS team needs-review Every commit must be reviewed by at least two team members, component-platform Portability layer and build scripts needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review labels Feb 22, 2022
@AndrzejKurek AndrzejKurek force-pushed the timeless-2.28 branch 5 times, most recently from 053ff42 to 8896c8d Compare February 22, 2022 18:49
@AndrzejKurek AndrzejKurek removed the needs-ci Needs to pass CI tests label Feb 22, 2022
@mpg
Copy link
Contributor

mpg commented Feb 23, 2022

@d3zd3z @tom-cosgrove-arm Since you reviewed the main PR, will you review this backport as well?

d3zd3z
d3zd3z previously approved these changes Feb 25, 2022
Copy link
Contributor

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@tom-cosgrove-arm
Copy link
Contributor

My comments on #3624 pretty much apply here too

daxtens and others added 9 commits March 4, 2022 15:25
Make it safe to import the config multiple times without having
multiple definition errors.

(This prevents errors in the fuzzers in a later patch.)

Signed-off-by: Daniel Axtens <[email protected]>
MBEDTLS_HAVE_TIME is documented as: "System has time.h and time()."

If that is not defined, do not attempt to include time.h.

A particular problem is platform-time.h, which should only be included if
MBEDTLS_HAVE_TIME is defined, which makes everything messier. Maybe it
should be refactored to have the check inside the header.

Signed-off-by: Daniel Axtens <[email protected]>
baremetal compiles should not include time.h, as MBEDTLS_HAVE_TIME is
undefined. To test this, provide an overriding include directory that
has a time.h which throws a meaningful error if included.

Signed-off-by: Daniel Axtens <[email protected]>
Signed-off-by: Raoul Strackx <[email protected]>
[dja: add some more fixes, tweak title]
Signed-off-by: Daniel Axtens <[email protected]>
To be able to test utility programs for an absence of time.h, we need a
baremetal config that is not crypto only. Add one.

Signed-off-by: Daniel Axtens <[email protected]>
Allow programs/test/udp_proxy.c to build when MBEDTLS_HAVE_TIME is
not defined. In this case, do not attempt to seed the pseudo-random
number generator used to sometimes produce corrupt packets and other
erroneous data.

Signed-off-by: David Horstmann <[email protected]>
MBEDTLS_HAVE_TIME_ALT implies MBEDTLS_HAVE_TIME, so an extra
check for MBEDTLS_HAVE_TIME is not needed.

Signed-off-by: David Horstmann <[email protected]>
Change the new baremetal all.sh tests to use $PWD rather than
calling pwd again directly.

Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: Andrzej Kurek <[email protected]>
Andrzej Kurek added 7 commits March 4, 2022 15:25
Also move the self test implementation guards 
so that alternate implementations must
provide their own.
Signed-off-by: Andrzej Kurek <[email protected]>
@AndrzejKurek
Copy link
Contributor Author

AndrzejKurek commented Mar 4, 2022

Pulled new commits from the original PR.
Changes compared to original:

  • timing.c has different structure and contains things from development's benchmark.c. I changed the guards to not compile selftest if MBEDTLS_TIMING_ALT is provided.
  • benchmark.c - in 2.28, mbedtls_timing_hardclock from timing.c doesn't use timing.c utilities, but is guarded by MBEDTLS_TIMING, thus benchmark requires it too (compared to development's MBEDTLS_HAVE_TIME). Other possible approach: refactor timing.c and benchmark.c to be more in line with development, letting benchmark work without MBEDTLS_TIMING, but with MBEDTLS_HAVE_TIME.

@AndrzejKurek AndrzejKurek requested a review from d3zd3z March 5, 2022 00:27
@AndrzejKurek AndrzejKurek removed the needs-reviewer This PR needs someone to pick it up for review label Mar 5, 2022
@@ -527,4 +527,44 @@ int mbedtls_timing_self_test( int verbose )

#endif /* MBEDTLS_SELF_TEST */

#else
volatile int mbedtls_timing_alarmed = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to this particular change, but volatile is insufficient to make this code correct on non-strongly ordered SMP targets (e.g. Arm).

@tom-cosgrove-arm tom-cosgrove-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, approved Design and code approved - may be waiting for CI or backports labels Mar 9, 2022
@tom-cosgrove-arm
Copy link
Contributor

CI failures: 1 x No such property: pullRequest for class: groovy.lang.Binding + 2 x ?

Internal CI all passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-platform Portability layer and build scripts enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants