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

KCM: fix memory leak #7823

Closed
wants to merge 1 commit into from

Conversation

alexey-tikhonov
Copy link
Member

@alexey-tikhonov alexey-tikhonov commented Feb 4, 2025

The copy of 'secret' argument - secret_val.data - was left hanging on sss_sec_ctx, effectively resulting in a memory leak. But this copy isn't actually required as this data isn't modified in below operations.
Skipping alloc+memcpy+erase is also beneficial performance wise.

:fixes:'sssd_kcm' memory leak was fixed.

@alexey-tikhonov alexey-tikhonov added no-backport This should go to target branch only. and removed branch: sssd-2-9 branch: sssd-2-9-4 Corresponds to C8S labels Feb 5, 2025
alexey-tikhonov added a commit to alexey-tikhonov/sssd that referenced this pull request Feb 5, 2025
`ldb_msg_add_value()` makes a copy under the hood, so there is no need
to make intermediate copy of `secret` argument.
This copy - `secret_val.data` - was left hanging on `sss_sec_ctx`, effectively
resulting in a memory leak.

This is a backport of SSSD#7823

:fixes:'sssd_kcm' memory leak was fixed.
@aplopez aplopez self-assigned this Feb 5, 2025
Copy link
Contributor

@aplopez aplopez left a comment

Choose a reason for hiding this comment

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

LGTM. And I like this solution more than the other one. Thank you.

@alexey-tikhonov
Copy link
Member Author

Added comments and edited commit message.

@alexey-tikhonov alexey-tikhonov marked this pull request as ready for review February 5, 2025 09:47
The copy of 'secret' argument - `secret_val.data` - was left hanging
on `sss_sec_ctx`, effectively resulting in a memory leak.
But this copy isn't actually required as this data isn't modified in
below operations.
Skipping alloc+memcpy+erase is also beneficial performance wise.

:fixes:'sssd_kcm' memory leak was fixed.
alexey-tikhonov added a commit to alexey-tikhonov/sssd that referenced this pull request Feb 5, 2025
The copy of 'secret' argument - `secret_val.data` - was left hanging
on `sss_sec_ctx`, effectively resulting in a memory leak.
But this copy isn't actually required as this data isn't modified in
below operations.

This is a backport of SSSD#7823

:fixes:'sssd_kcm' memory leak was fixed.
@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Feb 5, 2025
Copy link
Contributor

@justin-stephenson justin-stephenson left a comment

Choose a reason for hiding this comment

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

Ack, thank you.

@alexey-tikhonov alexey-tikhonov added Accepted Ready to push Ready to push branch: sssd-2-10 and removed Waiting for review no-backport This should go to target branch only. labels Feb 6, 2025
alexey-tikhonov added a commit that referenced this pull request Feb 7, 2025
The copy of 'secret' argument - `secret_val.data` - was left hanging
on `sss_sec_ctx`, effectively resulting in a memory leak.
But this copy isn't actually required as this data isn't modified in
below operations.

This is a backport of #7823

:fixes:'sssd_kcm' memory leak was fixed.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
alexey-tikhonov added a commit that referenced this pull request Feb 7, 2025
The copy of 'secret' argument - `secret_val.data` - was left hanging
on `sss_sec_ctx`, effectively resulting in a memory leak.
But this copy isn't actually required as this data isn't modified in
below operations.

This is a backport of #7823

:fixes:'sssd_kcm' memory leak was fixed.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
(cherry picked from commit 6aba9a7)
@alexey-tikhonov
Copy link
Member Author

@alexey-tikhonov
Copy link
Member Author

Pushed PR: #7823

  • master
  • sssd-2-10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants