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

Fix S2N blocked issue #589

Merged
merged 16 commits into from
Aug 10, 2023
Merged

Fix S2N blocked issue #589

merged 16 commits into from
Aug 10, 2023

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented Aug 7, 2023

Description of changes:
Fixes the use of s2n_recv. The blocked value is only guaranteed to be meaningful if s2n_error_get_type(s2n_errno) == S2N_ERR_T_BLOCKED. If the error type is something else, the blocked value is meaningless and cannot be relied on for any logic. Currently, the return values are all treated the same and if any fatal error occurs we can end up in an endless loop because blocked value can be garbage.

Example of how to integrate properly here. Note that you don't really even need to read the blocked value at all. It's simply there to tell you what type of blocking happened.

Another issue that can occur when multi-record mode is enabled is S2N will fill up the provided buffer entirely and the blocked status will have a "junk" value. Since the return value is >0 and s2n_error_get_type(s2n_errno) is not S2N_ERR_T_BLOCKED. The blocked value does end up with S2N_BLOCKED_ON_READ so, luckily, the loop exits. But as
there's no event to wake it back up because it wasn't actually blocked on a socket operation and we will end up never reading the rest of the data.

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

source/io.c Outdated Show resolved Hide resolved
include/aws/io/io.h Show resolved Hide resolved
source/s2n/s2n_tls_channel_handler.c Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2023

Codecov Report

Patch coverage: 40.00% and project coverage change: -0.05% ⚠️

Comparison is base (b8aba42) 79.94% compared to head (0e7ce5f) 79.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #589      +/-   ##
==========================================
- Coverage   79.94%   79.90%   -0.05%     
==========================================
  Files          27       27              
  Lines        5845     5848       +3     
==========================================
  Hits         4673     4673              
- Misses       1172     1175       +3     
Files Changed Coverage Δ
source/io.c 90.47% <ø> (ø)
source/s2n/s2n_tls_channel_handler.c 73.36% <40.00%> (-0.33%) ⬇️

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

@waahm7 waahm7 requested a review from camshaft August 8, 2023 23:55
} else {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: Error decrypting message. Unexpected type of output buffer.",
Copy link
Contributor

Choose a reason for hiding this comment

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

ask henso about this case
if this is the right way to handle it, or if he intended something else to happen

source/s2n/s2n_tls_channel_handler.c Outdated Show resolved Hide resolved
source/s2n/s2n_tls_channel_handler.c Outdated Show resolved Hide resolved
@waahm7 waahm7 merged commit c4b661f into main Aug 10, 2023
32 checks passed
@waahm7 waahm7 deleted the s2nfix branch August 10, 2023 21:19
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.

4 participants