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

[21435] Solve SecurityManager memory issue (backport #5115) #5121

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 30, 2024

Description

A memory issue is reported by ASAN when running tests using security such as BlackboxTests_DDS_PIM.Security.BuiltinAuthenticationPlugin_second_participant_creation_loop.

The issue is that the events thread might call SecurityManager::resend_handshake_message_token, which internally calls WriterHistory::remove_change_and_reuse, the latter not being (atomically) thread safe. If at the same time a handshake is processed (SecurityManager::on_process_handshake) from another thread, this may resolve in a change being added to the aforementioned writer history. As a result a change is added to History::m_changes vector, which would invalidate the iterator dealt with in WriterHistory::remove_change_and_reuse without protection.

Two potential solutions are proposed:

  • Take the history/endpoint mutex before calling WriterHistory::remove_change_and_reuse from the security manager, as it's done when calling PDPServer::remove_change_from_history_nts
  • Protect WriterHistory::remove_change_and_reuse fully, converting it in an atomic thread-safe method. Note that since the functions internally called from within this method already take the mutex, no (new) deadlocks should be introduced.

@Mergifyio backport 2.14.x 2.10.x

Contributor Checklist

  • Commit messages follow the project guidelines.

  • The code follows the style guidelines of this project.

  • N/A Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally

  • N/A: Any new/modified methods have been properly documented using Doxygen.

  • N/A: Any new configuration API has an equivalent XML API (with the corresponding XSD extension)

  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.

  • Changes are API compatible.

  • N/A: New feature has been added to the versions.md file (if applicable).

  • N/A: New feature has been documented/Current behavior is correctly described in the documentation.

  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

This is an automatic backport of pull request #5115 done by [Mergify](https://mergify.com).

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 0d996bc)
@mergify mergify bot mentioned this pull request Jul 30, 2024
11 tasks
@MiguelCompany MiguelCompany added this to the v2.10.5 milestone Jul 31, 2024
@MiguelCompany MiguelCompany self-requested a review July 31, 2024 06:43
@github-actions github-actions bot added the ci-pending PR which CI is running label Jul 31, 2024
Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@MiguelCompany MiguelCompany merged commit 44fddab into 2.10.x Jul 31, 2024
16 of 18 checks passed
@MiguelCompany MiguelCompany deleted the mergify/bp/2.10.x/pr-5115 branch July 31, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-pending PR which CI is running
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants