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

optimization capabilities missing in openssl fips provider #23979

Closed
nhorman opened this issue Mar 26, 2024 Discussed in #23978 · 1 comment
Closed

optimization capabilities missing in openssl fips provider #23979

nhorman opened this issue Mar 26, 2024 Discussed in #23978 · 1 comment
Labels
help wanted triaged: bug The issue/pr is/fixes a bug

Comments

@nhorman
Copy link
Contributor

nhorman commented Mar 26, 2024

Discussed in #23978

Originally posted by sanumesh March 26, 2024
Hello

I am using openssl 3.0.10 version and have built the fips provider using the make enable_fips flags for aix-cc platform.

However the openssl speed command shows that it is not using the hardware capabilities of Power, and instead uses the software implementations of the algorithms.
This is seen when fips provider is enabled in the openssl.cnf configuration file (with default disabled).

The issue is that the OPENSSL_cpuid_setup function which sets the power hardware capabilities (OPENSSL_ppccap_P variable) gets called only in the context of default provider.
Since fips provider is loaded as a shared object, it has its own copy of OPENSSL_ppccap_P which gets initialized to 0 as we do not call OPENSSL_cpuid_setup function in the context of FIPS provider. Since this value is 0, any algorithm implementation calls done with fips provider uses the software based implementation of the algorithms.

Can you advice how to fix this?

Thanks

@nhorman nhorman added the issue: bug report The issue was opened to report a bug label Mar 26, 2024
@t8m t8m added triaged: bug The issue/pr is/fixes a bug and removed issue: bug report The issue was opened to report a bug labels Mar 26, 2024
@nhorman nhorman added the severity: important Important bugs affecting a released version label Mar 26, 2024
@paulidale
Copy link
Contributor

I'm guessing the easy fix is to call OPENSSL_cpuid_setup from OSSL_provider_init_int.

@nhorman nhorman added help wanted and removed severity: important Important bugs affecting a released version labels Apr 29, 2024
ZenithalHourlyRate added a commit to ZenithalHourlyRate/openssl that referenced this issue May 16, 2024
Fixes: openssl#23979

Previously fips module relies on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug
openssl-machine pushed a commit that referenced this issue May 22, 2024
Fixes: #23979

Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24419)

(cherry picked from commit a192b24)
openssl-machine pushed a commit that referenced this issue May 22, 2024
Fixes: #23979

Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24419)

(cherry picked from commit a192b24)
openssl-machine pushed a commit that referenced this issue May 22, 2024
Fixes: #23979

Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24419)

(cherry picked from commit a192b24)
openssl-machine pushed a commit that referenced this issue May 22, 2024
Fixes: #23979

Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24419)

(cherry picked from commit a192b24)
jvdsn pushed a commit to jvdsn/openssl that referenced this issue Jun 3, 2024
Fixes: openssl#23979

Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#24419)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants