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

compile issue if MBEDTLS_CERTS_C is not set in 2.28.1 #6243

Closed
hauke opened this issue Aug 27, 2022 · 2 comments
Closed

compile issue if MBEDTLS_CERTS_C is not set in 2.28.1 #6243

hauke opened this issue Aug 27, 2022 · 2 comments
Labels
bug component-platform Portability layer and build scripts size-s Estimated task size: small (~2d)

Comments

@hauke
Copy link

hauke commented Aug 27, 2022

Summary

I am getting the following compile problem when compiling mbedtls 2.28.1 in OpenWrt master:

-- Build files have been written to: /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1
awk 'BEGIN { rc = 1 } /#define MBEDTLS_DEBUG_C/ { $0 = "// #define MBEDTLS_DEBUG_C"; rc = 0 } { print } END { exit(rc) }' /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h >/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h.new && mv /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h.new /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h
awk 'BEGIN { rc = 1 } /#define MBEDTLS_HKDF_C/ { $0 = "// #define MBEDTLS_HKDF_C"; rc = 0 } { print } END { exit(rc) }' /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h >/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h.new && mv /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h.new /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include/mbedtls/config.h
sed -i '/fuzz/d' /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/CMakeLists.txt
sed -i '/test/d' /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/CMakeLists.txt
touch /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/.configured_5e1d5ee8fa334bc8ae9c07800ce6707c
rm -f /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/.built
touch /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/.built_check
MAKEFLAGS="" /home/hauke/openwrt/openwrt/staging_dir/host/bin/ninja  -j1 -C /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1 
ninja: Entering directory `/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1'
[0/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1
[295/316] Building C object programs/ssl/CMakeFiles/ssl_server2.dir/ssl_server2.c.o
FAILED: programs/ssl/CMakeFiles/ssl_server2.dir/ssl_server2.c.o 
/home/hauke/openwrt/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/aarch64-openwrt-linux-musl-gcc  -I/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/ssl/../../tests/include -I/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/include -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1=mbedtls-2.28.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -ffunction-sections -fdata-sections -Wall -Wextra -Wwrite-strings -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -O2 -fPIE -MD -MT programs/ssl/CMakeFiles/ssl_server2.dir/ssl_server2.c.o -MF programs/ssl/CMakeFiles/ssl_server2.dir/ssl_server2.c.o.d -o programs/ssl/CMakeFiles/ssl_server2.dir/ssl_server2.c.o -c /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/ssl/ssl_server2.c
/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/ssl/ssl_server2.c: In function 'main':
/home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/programs/ssl/ssl_server2.c:4142:1: error: expected declaration or statement at end of input
 4142 | }
      | ^
ninja: build stopped: subcommand failed.
make[2]: *** [Makefile:142: /home/hauke/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/mbedtls-2.28.1/.built] Error 1
make[2]: Leaving directory '/home/hauke/openwrt/openwrt/package/libs/mbedtls'
time: package/libs/mbedtls/compile#30.75#2.63#32.45

OpenWrt builds for Linux and uses the following patch to adjust the default configuration:
https://github.com/openwrt/openwrt/blob/master/package/libs/mbedtls/patches/200-config.patch

I bisected it to this commit: 331c342

System information

Mbed TLS version: 2.28.1
Operating system and version: OpenWrt master (GCC 11.3, Linux 5.10, musl libc)
Configuration (if not default, please attach mbedtls_config.h): Default config + these changes: https://github.com/openwrt/openwrt/blob/master/package/libs/mbedtls/patches/200-config.patch
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): (GCC 11.3, Linux 5.10, musl libc)
Additional environment information:

Expected behavior

It should compile.

Actual behavior

It does not compile.

Steps to reproduce

Compile mbedtls 2.28.1 with this patch: https://github.com/openwrt/openwrt/blob/master/package/libs/mbedtls/patches/200-config.patch

Additional information

mbedtls 2.28.0 compiles fine.

The following patch fixed it for me:

Fix a compile problem introduced in commit 331c3421d1f0 ("Address review comments")

--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -2511,7 +2511,6 @@ int main( int argc, char *argv[] )
         }
         key_cert_init2 = 2;
 #endif /* MBEDTLS_ECDSA_C */
-    }
 
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
     if( opt.key_opaque != 0 )
@@ -2540,6 +2539,7 @@ int main( int argc, char *argv[] )
     }
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
 #endif /* MBEDTLS_CERTS_C */
+    }
 
     mbedtls_printf( " ok (key types: %s - %s)\n", mbedtls_pk_get_name( &pkey ), mbedtls_pk_get_name( &pkey2 ) );
 #endif /* MBEDTLS_X509_CRT_PARSE_C */

I haven't signed the CLA.

hauke added a commit to hauke/openwrt that referenced this issue Aug 27, 2022
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.1
This release of Mbed TLS provides bug fixes and minor enhancements. This
release includes fixes for security issues.

The build problem was reported upstream:
Mbed-TLS/mbedtls#6243

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
jow- pushed a commit to lede-project/source that referenced this issue Aug 28, 2022
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.1
This release of Mbed TLS provides bug fixes and minor enhancements. This
release includes fixes for security issues.

The build problem was reported upstream:
Mbed-TLS/mbedtls#6243

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
jow- pushed a commit to openwrt/openwrt that referenced this issue Aug 28, 2022
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.1
This release of Mbed TLS provides bug fixes and minor enhancements. This
release includes fixes for security issues.

The build problem was reported upstream:
Mbed-TLS/mbedtls#6243

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit f387054)
@minosgalanakis minosgalanakis added bug help-wanted This issue is not being actively worked on, but PRs welcome. component-platform Portability layer and build scripts good-first-issue Good for newcomers size-s Estimated task size: small (~2d) labels Aug 30, 2022
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this issue Sep 1, 2022
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.1
This release of Mbed TLS provides bug fixes and minor enhancements. This
release includes fixes for security issues.

The build problem was reported upstream:
Mbed-TLS/mbedtls#6243

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
devendranaga pushed a commit to devendra-naga-labs/bsp_build that referenced this issue Sep 8, 2022
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.1
This release of Mbed TLS provides bug fixes and minor enhancements. This
release includes fixes for security issues.

The build problem was reported upstream:
Mbed-TLS/mbedtls#6243

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Feb 1, 2023
This broke the build when MBEDTLS_CERTS_C is undefined. Fixes Mbed-TLS#6243.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm removed help-wanted This issue is not being actively worked on, but PRs welcome. good-first-issue Good for newcomers labels Feb 1, 2023
@gilles-peskine-arm gilles-peskine-arm added this to Mbed TLS 3.4 release in EPICs for Mbed TLS Feb 1, 2023
@gilles-peskine-arm
Copy link
Contributor

Apologies for not fixing this in 2.28.2. We hadn't classified this as a regression, but looking closer we should have. The fix should be in 2.28.3.

Note that your patch is only correct when MBEDTLS_USE_PSA_CRYPTO is disabled (it is by default).

@daverodgman daverodgman added this to Mbed TLS 3.4 release in Backlog for Mbed TLS Feb 22, 2023
@daverodgman daverodgman removed this from Mbed TLS 3.4 release in EPICs for Mbed TLS Feb 22, 2023
@daverodgman daverodgman added this to Mbed TLS 3.4 release in EPICs for Mbed TLS Feb 22, 2023
@daverodgman daverodgman removed this from Mbed TLS 3.4 release in Backlog for Mbed TLS Feb 22, 2023
@gilles-peskine-arm
Copy link
Contributor

The fix in #7013 has been merged.

hauke added a commit to hauke/openwrt that referenced this issue Apr 10, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
pull bot pushed a commit to mingxiaoyu/immortalwrt that referenced this issue Apr 12, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this issue Apr 12, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
hauke added a commit to hauke/openwrt that referenced this issue Aug 11, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit d679b15)
hauke added a commit to hauke/openwrt that referenced this issue Aug 12, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit d679b15)
edofullin pushed a commit to edofullin/openwrt_mapt_mods that referenced this issue Sep 10, 2023
This only fixes minor problems.
Changelog: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.3

The 100-fix-compile.patch patch was merged upstream, see:
Mbed-TLS/mbedtls#6243
Mbed-TLS/mbedtls#7013

The code style of all files in mbedtls 2.28.3 was changed. I took a new
version of the 100-x509-crt-verify-SAN-iPAddress.patch patch from this
pull request: Mbed-TLS/mbedtls#6475

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit d679b15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-platform Portability layer and build scripts size-s Estimated task size: small (~2d)
Projects
None yet
Development

No branches or pull requests

3 participants