Cherry-pick: Fix out-of-bound (OOB) input read in AES-XTS Decrypt in AVX-512 implementation#2228
Merged
nebeid merged 1 commit intoaws:fips-2024-09-27from Feb 28, 2025
Conversation
…mentation (aws#2227) - Fix instruction that caused out-of-bound read in the input reading of the 16x loop (which processes a batch of 16 blocks of AES, 1 block = 16 bytes). This was triggered on lengths that are in the range [16*k * (16 bytes), (16*k +3)* (16 bytes)-1], k = 1, 2, ... The instruction was reading up to 3*16 bytes beyond the input length bound. - The fix was inspired by the 8x loop in https://github.com/aws/aws-lc/blob/becf5785c131012bb5a64f3da6cdb117ddc0f431/crypto/fipsmodule/aes/asm/aesni-xts-avx512.pl#L2544 - The existing unit tests cover those cases but there were no explicit memory protections and ASAN doesn't instrument assembly code to check for out-of-bound reads even when the subsequent memory is explicitly poisoned. ### Call-outs: N/A ### Testing: On c6i, without the fix, the unit test segfaults ``` ./crypto/crypto_test "--gtest_filter=XTSTest.*" Note: Google Test filter = XTSTest.* [==========] Running 4 tests from 1 test suite. [----------] Global test environment set-up. [----------] 4 tests from XTSTest [ RUN ] XTSTest.TestVectors Segmentation fault (core dumped) ``` 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.
darylmartin100
approved these changes
Feb 28, 2025
torben-hansen
approved these changes
Feb 28, 2025
nebeid
added a commit
that referenced
this pull request
Apr 22, 2025
…lace SSE instructions that degraded performance for certain input lengths (#2319) Original commits: a39439b and 37c2b5e This is a follow-up to #2228 where an out-of-bound (OOB) read was fixed in the AVX512 implementation of AES-XTS and more tests were added. This cherry-picks: - further hardening tests on checking pre-bound reads #2286 - a fix to a performance glitch on a code path that had an SSE instruction instead of an AVX512 one which was triggered by certain input lengths. #2140 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original PR: #2227
Cherry-pick eb0c0c0
Fix instruction that caused out-of-bound read in the input reading of the 16x loop (which processes a batch of 16 blocks of AES, 1 block = 16 bytes). This was triggered on lengths that are in the range [16k * (16 bytes), (16k +3)* (16 bytes)-1], k = 1, 2, ... The instruction was reading up to 3*16 bytes beyond the input length bound.
The fix was inspired by the 8x loop in
aws-lc/crypto/fipsmodule/aes/asm/aesni-xts-avx512.pl
Line 2544 in becf578
The existing unit tests cover those cases but there were no explicit memory protections and ASAN doesn't instrument assembly code to check for out-of-bound reads even when the subsequent memory is explicitly poisoned.
Call-outs:
N/A
Testing:
On c6i, without the fix, the unit test segfaults
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.