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: UpgradePackBuilderFacade setting mbedtls global memory pool on stack #324

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

BarisTanyeri
Copy link
Contributor

Summary

  • This PR fixes the crash when ConnectionMbedTls is combined with UpgradePackBuilderFacade

Issue Reproduction

1- Create ConnectionMbedTls
2- Run UpgradePackBuilderFacade
3- Attempt to create ConnectionMbedTls for another host
4- Observe failure on mbedtls_ssl_session_free()

Details

  • When UpgradePackBuilderFacade is combined with ConnectionMbedTls, connection memory pool is allocated on the heap. However, UpgradePackBuilderFacade sets global mbed tls buffers on stack, which then causes free() to be called on heap pointers in the context of stack.
  • When MBEDTLS_MEMORY_DEBUG is defined; FATAL: mbedtls_free() outside of managed space is printed. This indicates either the memory pool is corrupted or the pointers. In this case, mbedtls memory pool is set to stack memory while initialization of a ConnectionMbedTls had been done on the heap. When ConnectionMbedTls tries to free its resources in the pool, because the pool has changed, this operation becomes invalid and causes the program to exit.

…tack, causing a crash when combined with ConnectionMbedTls
@BarisTanyeri BarisTanyeri requested a review from a team as a code owner June 15, 2023 15:24
@github-actions
Copy link
Contributor

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 11 0 0.11s
✅ DOCKERFILE hadolint 1 0 0.12s
✅ JSON eslint-plugin-jsonc 10 0 0 5.15s
✅ JSON prettier 10 0 0 0.68s
⚠️ MARKDOWN markdownlint 7 0 11 0.71s
⚠️ MARKDOWN markdown-link-check 7 1 54.53s
✅ MARKDOWN markdown-table-formatter 7 0 0 0.48s
✅ YAML prettier 20 0 0 1.21s
✅ YAML v8r 20 0 10.53s
✅ YAML yamllint 20 0 0.36s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@sonarcloud
Copy link

sonarcloud bot commented Jun 15, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@BarisTanyeri BarisTanyeri added this pull request to the merge queue Jun 19, 2023
Merged via the queue into main with commit ec567d5 Jun 19, 2023
25 checks passed
@BarisTanyeri BarisTanyeri deleted the feature/fix_mbed_tls_global_buffer branch June 19, 2023 08:03
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.

None yet

2 participants