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 potential peer_state deadlocks in finish_force_close_channel #2597

Conversation

TheBlueMatt
Copy link
Collaborator

ChannelManager::finish_force_close_channel exists to do cleanups which must happen without the per_peer_state mutex held. However, because it lacked lock assertions, several changes snuck in recently which resulted in it running with peer-state locks held, risking a deadlock if some HTLCs need to be failed.

@TheBlueMatt TheBlueMatt added this to the 0.0.117 milestone Sep 25, 2023
dunxen
dunxen previously approved these changes Sep 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ce74634) 88.85% compared to head (20e1c27) 88.86%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2597   +/-   ##
=======================================
  Coverage   88.85%   88.86%           
=======================================
  Files         113      113           
  Lines       84482    84517   +35     
  Branches    84482    84517   +35     
=======================================
+ Hits        75069    75103   +34     
+ Misses       7213     7211    -2     
- Partials     2200     2203    +3     
Files Coverage Δ
lightning/src/ln/shutdown_tests.rs 96.66% <100.00%> (+0.06%) ⬆️
lightning/src/ln/channelmanager.rs 81.56% <96.29%> (+0.14%) ⬆️

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@valentinewallace
Copy link
Contributor

Feel free to squash

`ChannelManager::finish_force_close_channel` exists to do cleanups
which must happen without the `per_peer_state` mutex held. However,
because it lacked lock assertions, several changes snuck in
recently which resulted in it running with peer-state locks held,
risking a deadlock if some HTLCs need to be failed.
We have code to handle receiving `shutdown` messages on unfudned
channels. However, it had no test coverage, which we add here.
@TheBlueMatt TheBlueMatt force-pushed the 2023-09-finish-force-close-deadlocks branch from 913a330 to 20e1c27 Compare September 26, 2023 00:38
@TheBlueMatt
Copy link
Collaborator Author

Squashed.

Comment on lines +267 to +270
// P2WSH
let script = Builder::new().push_int(0)
.push_slice(&[0; 20])
.into_script();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: P2WPKH*

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦 Will fix in #2591

@TheBlueMatt TheBlueMatt merged commit 827b17c into lightningdevkit:main Sep 26, 2023
14 of 15 checks passed
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

5 participants