Fix race between critnib_release() and free_leaf() in critnib - #1362
Merged
ldorau merged 2 commits intoJun 16, 2025
Merged
Conversation
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
4 times, most recently
from
June 9, 2025 16:56
83ace89 to
8558628
Compare
ldorau
marked this pull request as draft
June 10, 2025 06:23
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
from
June 10, 2025 09:09
2da9574 to
bd5621a
Compare
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
7 times, most recently
from
June 11, 2025 17:42
3aac31d to
4254ffb
Compare
ldorau
marked this pull request as ready for review
June 11, 2025 19:18
Contributor
Author
|
PR is ready for review. |
Contributor
Author
bratpiorka
reviewed
Jun 12, 2025
bratpiorka
reviewed
Jun 12, 2025
bratpiorka
approved these changes
Jun 12, 2025
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
from
June 12, 2025 11:34
4254ffb to
1ac3d97
Compare
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
from
June 12, 2025 11:40
1ac3d97 to
188aa5c
Compare
Contributor
Author
|
@bratpiorka Done |
bratpiorka
approved these changes
Jun 13, 2025
Contributor
Author
|
@lplewa please review |
lplewa
approved these changes
Jun 16, 2025
| utils_atomic_store_release_u8(&k->pending_deleted_leaf, 0); | ||
| add_to_deleted_leaf_list(c, k); | ||
| do { | ||
| utils_atomic_load_acquire_u64(&k->ref_count, &ref_count); |
Contributor
There was a problem hiding this comment.
Do we need this load here? Compare and do load of refcount anyway
Contributor
Author
There was a problem hiding this comment.
Right. Moved before the do while ().
Done.
Fix race between critnib_release() and free_leaf() in critnib: critnib_release() decremented ref_count to 0 and (before it called c->cb_free_leaf(k->to_be_freed)) free_leaf() added this leaf to the c->deleted_leaf list and alloc_leaf() reused it and zeroed k->to_be_freed before it could be freed in critnib_release(). This patch fixes this issue. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
ldorau
force-pushed
the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
from
June 16, 2025 10:30
188aa5c to
02cc039
Compare
ldorau
deleted the
Fix_race_between_critnib_release_and_free_leaf_in_critnib
branch
June 17, 2025 06:44
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.
Description
Fix race between critnib_release() and free_leaf() in critnib:
critnib_release() decremented ref_count to 0 and (before it called c->cb_free_leaf(k->to_be_freed))
free_leaf() added this leaf to the c->deleted_leaf list and alloc_leaf() reused it
and zeroed k->to_be_freed before it could be freed in critnib_release().
This patch fixes this issue.
Checklist