Skip to content

Conversation

@hanno-becker
Copy link
Contributor

@hanno-becker hanno-becker commented Mar 28, 2025

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.


On AArch64, the delocator can patch up the computation of function pointers only if the pointers can be computed with a PC-relative offset in the range (-1MB, 1MB).

For the function pointer computations in aes/mode_wrappers.c, this bounds condition is about to be violated by further code additions to AWS-LC, as witnessed in AES-unrelated PRs (specifically #2176).

This commit preventatively fixes the issue by adding function pointer trampolines to crypto/fipsmodule/aes/mode_wrappers.c: These are stub functions immediately branching into the desired assembly routines, but close enough to the C code computing their address to ensure that their addresses will be computable using a PC-relative offset.

This fix is similar to #2165.

Mid/Long-term, it should be considered whether the delocator can introduce the necessary indirections automatically.

@hanno-becker hanno-becker requested a review from a team as a code owner March 28, 2025 04:18
@hanno-becker hanno-becker requested review from justsmth and nebeid March 28, 2025 04:18
@hanno-becker hanno-becker marked this pull request as draft March 28, 2025 04:20
@hanno-becker hanno-becker force-pushed the aes_jump_trampoline branch 3 times, most recently from 4c8136d to c212ddf Compare March 28, 2025 04:28
@hanno-becker hanno-becker marked this pull request as ready for review March 28, 2025 04:49
@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.04%. Comparing base (1cbed51) to head (f9b104e).

Files with missing lines Patch % Lines
crypto/fipsmodule/aes/mode_wrappers.c 33.33% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2294      +/-   ##
==========================================
- Coverage   79.05%   79.04%   -0.01%     
==========================================
  Files         614      614              
  Lines      107042   107051       +9     
  Branches    15161    15160       -1     
==========================================
+ Hits        84619    84620       +1     
- Misses      21771    21779       +8     
  Partials      652      652              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

On AArch64, the delocator can patch up the computation of function
pointers only if the pointers can be computed with a PC-relative
offset in the range (-1MB, 1MB).

For the function pointer computations in aes/mode_wrappers.c,
this bounds condition is about to be violated by further code
additions to AWS-LC, as witnessed in AES-unrelated PRs.

This commit preventatively fixes the issue by adding function
pointer trampolines to crypto/fipsmodule/aes/mode_wrappers.c:
These are stub functions immediately branching into the desired
assembly routines, but close enough to the C code computing their
address to ensure that their addresses will be computable using
a PC-relative offset.

This fix is similar to aws#2165.

Mid/Long-term, it should be considered whether the delocator
can introduce the necessary indirections automatically.

Signed-off-by: Hanno Becker <[email protected]>
@nebeid nebeid merged commit cce6b79 into aws:main Mar 28, 2025
106 of 109 checks passed
@smittals2 smittals2 mentioned this pull request Mar 28, 2025
skmcgrail added a commit that referenced this pull request Mar 28, 2025
## What's Changed
* Revert "Allow constructed strings in BER parsing (#2015)" by
@samuel40791765 in #2278
* Add the rehash utility to the openssl CLI tool by @smittals2 in
#2258
* Documentation on service indicator by @justsmth in
#2281
* Update patches in Ruby CI by @samuel40791765 in
#2233
* Reject DSA trailing garbage in EVP layer, add test cases by @skmcgrail
in #2289
* Add support for verifying PKCS7 signed attributes by @samuel40791765
in #2264
* Add support for more SSL BIO functions by @samuel40791765 in
#2273
* Wire-up rust-openssl into GitHub CI (for the time being) by @skmcgrail
in #2291
* Adding detection of out-of-bound pre-bound memory read to AES-XTS
tests. by @nebeid in #2286
* AES: Add function pointer trampoline to avoid delocator issue by
@hanno-becker in #2294
* Bump mysql CI to 9.2.0 by @samuel40791765 in
#2161
* Cherrypick hardening DSA param checks from BoringSSL by @smittals2 in
#2293

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
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.

5 participants