Skip to content

Comments

bn_nist: fix strict aliasing problem#18258

Closed
paulidale wants to merge 2 commits intoopenssl:masterfrom
paulidale:fix-18225
Closed

bn_nist: fix strict aliasing problem#18258
paulidale wants to merge 2 commits intoopenssl:masterfrom
paulidale:fix-18225

Conversation

@paulidale
Copy link
Contributor

As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes #18225

I'd like to wait until llvm/llvm-project#55255 gets commented on before commiting this.

As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes openssl#18225
@paulidale paulidale added branch: master Applies to master branch approval: review pending This pull request needs review by a committer approval: otc review pending branch: 3.0 Applies to openssl-3.0 branch labels May 6, 2022
@paulidale paulidale self-assigned this May 6, 2022
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label May 6, 2022
Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

I like this.

@t8m t8m added the triaged: bug The issue/pr is/fixes a bug label May 6, 2022
@guidovranken
Copy link
Contributor

@paulidale
Copy link
Contributor Author

paulidale commented May 9, 2022

Thanks for the counterpoint @guidovranken, @t8m any thoughts on which approach you prefer?

@bernd-edlinger
Copy link
Member

I would rather lower the global optimization level for this compiler version.

@paulidale
Copy link
Contributor Author

We'd need to drop it to -O1 or less. -O2 adds -fstrict-aliasing. We could single this file out for -fno-strict-aliasing, or perhaps just build everything with -fno-strict-aliasing since it isn't going to hurt the assembly code.

@t8m
Copy link
Member

t8m commented May 9, 2022

I prefer the fix as is in this PR. It fixes the UB as it keeps the union visible in the macro.

@t-j-h t-j-h added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels May 9, 2022
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels May 10, 2022
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@paulidale
Copy link
Contributor Author

Merged.

@paulidale paulidale closed this May 10, 2022
openssl-machine pushed a commit that referenced this pull request May 10, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes #18225

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #18258)
openssl-machine pushed a commit that referenced this pull request May 10, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes #18225

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #18258)

(cherry picked from commit 8712db5)
@mattcaswell
Copy link
Member

Any reason this wasn't backported to 1.1.1? The original issue says that 1.1.1 is also affected

mattcaswell pushed a commit to mattcaswell/openssl that referenced this pull request Aug 3, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes openssl#18225

Backport of openssl#18258 to 1.1.1.
@mattcaswell
Copy link
Member

Any reason this wasn't backported to 1.1.1? The original issue says that 1.1.1 is also affected

I created a backport in #18948

openssl-machine pushed a commit that referenced this pull request Aug 17, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes #18225

Backport of #18258 to 1.1.1.

Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #18948)
@paulidale paulidale deleted the fix-18225 branch September 5, 2022 00:22
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 9, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes openssl#18225

Backport of openssl#18258 to 1.1.1.

Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#18948)

(cherry picked from commit 6246649)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 9, 2022
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes openssl#18225

Backport of openssl#18258 to 1.1.1.

Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#18948)

(cherry picked from commit 6246649)
a-kromm-rogii pushed a commit to a-kromm-rogii/openssl that referenced this pull request Mar 14, 2025
As of clang-14 the strict aliasing is causing code to magically disappear.
By explicitly inlining the code, the aliasing problem evaporates.

Fixes openssl#18225

Backport of openssl#18258 to 1.1.1.

Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#18948)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch branch: 3.0 Applies to openssl-3.0 branch severity: fips change The pull request changes FIPS provider sources triaged: bug The issue/pr is/fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elliptic Curve code without ASM is broken with Clang 14

7 participants