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.7: Clarify that the full config enables everything that can be tested together #3295

Merged

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Apr 30, 2020

This is a partial backport of #3190. It is mostly similar to the 2.16 backport. Differences with the 2.16 backport:

  • A few commits didn't cherry-pick cleanly, but are replicated with the same semantics: sort lists. some places to split USAGE, fewer all.sh components with MBEDTLS_PLATFORM_NV_SEED_ALT.
  • In 2.16 and development, the code was supposed to be strict C99 without relying on GCC extensions, but this wasn't the case in some modules, and we didn't catch it because we didn't test it enough. In 2.7, it's less clear that the code was supposed to be strict C99: we only tested it in builds without platform features. See the comment below. So I skipped the commit that adds a -std=c99 build in the full configuration and some of the commits to strict-c99-ify the code. I kept strict-c99-ification commits only where there was an advantage to including the commit to keep the code aligned between branches to facilitate future backports. None of these risk of breaking the build on some “weird” platform where macros like _POSIX_C_SOURCE are not compliant.
    If we decide that 2.7 should compile with gcc -std=c99, let's do that in a separate PR that backports parts of gmtime_r and mbedtls_time on Windows #1198 and Backport 2.7: Clarify that the full config enables everything that can be tested together  #3295 and does whatever else is necessary.

These options haven't existed for a long time.

Signed-off-by: Gilles Peskine <[email protected]>
Enable MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 in the full config. There's
no reason to keep it out. We weren't testing it at all on the CI.

Signed-off-by: Gilles Peskine <[email protected]>
Remove the duplicated, and often out-of-date, list in the comments.
Instead explain in a comment, and have a single copy of the list which
is in the code.

Signed-off-by: Gilles Peskine <[email protected]>
The intended logic around MBEDTLS_xxx_ALT is to exclude them from full
because they require the alternative implementation of one or more
library functions, except that MBEDTLS_PLATFORM_xxx_ALT are different:
they're alternative implementations of a platform function and they
have a built-in default, so they should be included in full. Document
this.

Fix a bug whereby MBEDTLS_PLATFORM_xxx_ALT didn't catch symbols where
xxx contains an underscore. As a consequence, MBEDTLS_PLATFORM_NV_SEED_ALT
is now enabled in the full config. Explicitly exclude
MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT because it behaves like the
non-platform ones, requiring an extra build-time dependency.
Explicitly exclude MBEDTLS_PLATFORM_NV_SEED_ALT from baremetal
because it requires MBEDTLS_ENTROPY_NV_SEED, and likewise explicitly
unset it from builds that unset MBEDTLS_ENTROPY_NV_SEED.

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added mbed TLS team needs-review Every commit must be reviewed by at least two team members, component-platform Portability layer and build scripts labels Apr 30, 2020
mpg
mpg previously approved these changes Apr 30, 2020
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

This looks to me like a faithful backport of the 2.16 backport.

@gilles-peskine-arm gilles-peskine-arm added needs-ci Needs to pass CI tests needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Apr 30, 2020
An earlier botched backport (d56ca65)
had the wrong name for a variable and a missing header inclusion.

Signed-off-by: Gilles Peskine <[email protected]>
It works in practice on almost every platform, given that we're only
using the wrong type in cases where the value is guaranteed to stay
within the value bits of a signed int. But even in this case it may or
may not be strictly conforming. Anyway `gcc -std=c99 -pedantic`
rejects it.

Signed-off-by: Gilles Peskine <[email protected]>
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

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

Fine by me. Same typo as in 2.16.

}

component_test_full_deprecated_warning () {
# Test that there is nothing deprecated in the full configuraration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same typo as in 2.16.

@ronald-cron-arm
Copy link
Contributor

It seems the CI is not completely happy though.

@gilles-peskine-arm
Copy link
Contributor Author

It turns out that 2.7 hadn't had the benefit of 2682edf. That patch changes how some library files are built, and I'd prefer not to do that in an LTS branch if there isn't a good reason. “It breaks on some platform that someone cares about” would be a good reason, but I don't think “it removes a difference between branches” is.

So I'm going to rework this PR to not start doing a build in strict c99 mode with the platform code enabled. In 2.7, unlike the more recent versions, only no-platform builds pass in strict c99 mode.

Don't use string literals that are longer than 4095 bytes, which is
the minimum that C99 compilers are required to support. Compilers are
extremely likely to support longer literals, but `gcc -std=c99 -pedantic`
complains.

Signed-off-by: Gilles Peskine <[email protected]>
In the full config, don't set MBEDTLS_DEPRECATED_WARNING. This is debatable:
the full config does not enable deprecated features in this branch, so
MBEDTLS_DEPRECATED_WARNING is compatible with the other features.
Exclude it to keep LTS branches closer to development.

In any case, baremetal and full should have the same settings regarding
deprecated features, so don't do anything about DEPRECATED_xxx in baremetal.

Signed-off-by: Gilles Peskine <[email protected]>
build_deprecated combined the testing of deprecated features, and
testing of the build without deprecated features. Also, it violated the
component naming convention by being called build_xxx but running tests.

Replace it by:
* test_default_no_deprecated: check that you can remove deprecated
  features from the default build.
* test_full_deprecated_warning: check that enabling DEPRECATED_WARNING
  doesn't cause any warning from our own code.

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed needs-ci Needs to pass CI tests labels May 4, 2020
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

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

I checked the diff between this new version and the previous one and the differences are those explained in the PR first comment (#3295 (comment)) which I agree with. LGTM.

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Same as Ronald.

@mpg mpg 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, labels May 4, 2020
@danh-arm danh-arm merged commit af71b95 into Mbed-TLS:mbedtls-2.7 May 4, 2020
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 component-platform Portability layer and build scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants