Skip to content

Comments

Compile FIPS 140 integrity check only when building shared library#23

Closed
ueno wants to merge 2 commits intosmuellerDD:masterfrom
ueno:wip/static2
Closed

Compile FIPS 140 integrity check only when building shared library#23
ueno wants to merge 2 commits intosmuellerDD:masterfrom
ueno:wip/static2

Conversation

@ueno
Copy link
Contributor

@ueno ueno commented Mar 17, 2025

When leancrypto is compiled as a static library with
-Ddefault_library=static, it fails with:

../internal/src/fips_integrity_checker_elf.c:77:10: fatal error: fips_integrity_checker_values.h: No such file or directory
   77 | #include "fips_integrity_checker_values.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Given the FIPS 140 integrity check only works with shared library, as
it utilizes the ELF sections, this adds an extra check on
build_shared to avoid the compilation error.

Originally spotted by GnuTLS CI at: https://gitlab.com/dueno/gnutls/-/jobs/9425635915#L509

ueno added 2 commits March 17, 2025 14:39
When leancrypto is compiled as a static library with
-Ddefault_library=static, it fails with:

```
../internal/src/fips_integrity_checker_elf.c:77:10: fatal error: fips_integrity_checker_values.h: No such file or directory
   77 | #include "fips_integrity_checker_values.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Given the FIPS 140 integrity check only works with shared library, as
it utilizes the ELF sections, this adds an extra check on
build_shared to avoid the compilation error.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
Signed-off-by: Daiki Ueno <dueno@redhat.com>
@ueno
Copy link
Contributor Author

ueno commented Mar 17, 2025

Not sure about the CI failures; all tests with -Ddefault_library=shared/static/both succeed on my environment (Fedora 41).

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 18, 2025 via email

@ueno
Copy link
Contributor Author

ueno commented Mar 18, 2025

Thank you for merging and fixing the issue with constructor :-)

Daiki, do you happen to have an idea why the constructors are not executed
when compiling the library statically?

Afaik constructors are run by a dynamic linker, after determining the correct order of initialization/finalization, so there is no way to ensure that with static libraries:
https://www.akkadia.org/drepper/dsohowto.pdf#page=12

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 18, 2025 via email

@smuellerDD smuellerDD closed this Mar 19, 2025
@ueno
Copy link
Contributor Author

ueno commented Mar 19, 2025

Thank you; I've filed https://gitlab.com/gnutls/gnutls/-/merge_requests/1942

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.

2 participants