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 a heap-use-after-free bug in cluster bus #1643

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

xingbowang
Copy link
Contributor

#1642

A heap-use-after-free is found in cluster bus code.

freeClusterNode free the human_nodename. https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1725
Then it calls freeClusterLink to free the links. https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1730
freeClusterLink print human_nodename here, which just got freed by the caller freeClusterNode. https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1383

Copy link
Collaborator

@hpatro hpatro left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.86%. Comparing base (4b8f3ed) to head (caa6519).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1643      +/-   ##
============================================
- Coverage     70.98%   70.86%   -0.13%     
============================================
  Files           121      121              
  Lines         65176    65176              
============================================
- Hits          46267    46186      -81     
- Misses        18909    18990      +81     
Files with missing lines Coverage Δ
src/cluster_legacy.c 87.36% <100.00%> (+0.18%) ⬆️

... and 7 files with indirect coverage changes

@hpatro
Copy link
Collaborator

hpatro commented Jan 29, 2025

@pieturin
Copy link
Contributor

Thank you for the fix. This was due to the new debug log I introduced in freeClusterLink() in one of my previous PRs. The fix looks good.

@xingbowang
Copy link
Contributor Author

Will fix the DCO.

@hpatro hpatro merged commit ff8a528 into valkey-io:unstable Jan 29, 2025
50 checks passed
enjoy-binbin pushed a commit to enjoy-binbin/valkey that referenced this pull request Feb 2, 2025
valkey-io#1642

Avoid heap-use-after-free in cluster bus around node cleanup code.

freeClusterNode free the human_nodename.
https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1725
Then it calls freeClusterLink to free the links.
https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1730
freeClusterLink print human_nodename here, which just got freed by the
caller freeClusterNode.
https://github.com/valkey-io/valkey/blob/unstable/src/cluster_legacy.c#L1383

Signed-off-by: xingbowang <[email protected]>
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.

3 participants