Bugfix: Wallet: Lock cs_wallet for SignMessage #26130

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:fix_descrwallet_signmsg_deadlck changing 1 files +1 −0
  1. luke-jr commented at 12:49 AM on September 20, 2022: member

    cs_desc_main is typically locked within scope of a cs_wallet lock, but:

    CWallet::IsLocked locks cs_wallet ...called from DescriptorScriptPubKeyMan::GetKeys ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

    Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first


    Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by #26082 (CI fails as a result)

  2. Bugfix: Wallet: Lock cs_wallet for SignMessage
    cs_desc_main is typically locked within scope of a cs_wallet lock, but:
    
    CWallet::IsLocked locks cs_wallet
    ...called from DescriptorScriptPubKeyMan::GetKeys
    ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet
    ...called from DescriptorScriptPubKeyMan::SignMessage
    ...called from CWallet::SignMessage which can access and lock cs_wallet
    
    Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first
    a60d9eb9e6
  3. luke-jr commented at 12:50 AM on September 20, 2022: member

    (It would be good to have someone more familiar with descriptor wallet code take a look if there's a better way to fix this.)

  4. DrahtBot commented at 7:45 AM on September 20, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24058 (BIP-322 basic support by kallewoof)
    • #16545 (refactor: Implement missing error checking for ArgsManager flags by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. achow101 commented at 4:00 PM on September 22, 2022: member

    ACK a60d9eb9e6b6a272a3fca8981d89a55955dced55

    Note that the signmessage RPC does not run into this issue because the RPC function holds cs_wallet prior to calling CWallet::SignMessage.

  6. w0xlt approved
  7. w0xlt commented at 5:42 PM on September 22, 2022: contributor
  8. achow101 commented at 5:46 PM on September 22, 2022: member

    But most CI checks are failing with an unclear message.

    I think it needs to be rebased.

  9. luke-jr commented at 7:09 PM on September 22, 2022: member

    But most CI checks are failing with an unclear message.

    This is a CI bug.

    Edit: To be more specific, it looks like the CI infra is handling it okay, but some older CI distros have a very old version of git that can't handle the merge.

  10. fanquake commented at 9:02 AM on September 23, 2022: member

    but some older CI distros

    The majority of the failing jobs are using Ubuntu Focal, which was released 2 years ago, and is LTS for another 3 years.

    have a very old version of git

    Ubuntu Focal ships with git version 2.25, which was released ~2.5 years ago.

  11. hebasto commented at 9:44 AM on September 23, 2022: member

    But most CI checks are failing with an unclear message.

    I think it needs to be rebased.

    ... but some older CI distros have a very old version of git that can't handle the merge.

    Confirming that rebasing does help.

  12. glozow added the label Wallet on Sep 23, 2022
  13. luke-jr commented at 5:50 PM on September 23, 2022: member

    Looks like the minimum git to make the merge is 2.33. But the PR itself is fine as-is, and once merged won't be a problem even for old versions of git.

  14. MarcoFalke merged this on Sep 24, 2022
  15. MarcoFalke closed this on Sep 24, 2022

  16. fanquake added this to the milestone 24.0 on Sep 24, 2022
  17. fanquake commented at 2:28 PM on September 24, 2022: member

    @achow101 are we backporting this for 24.x?

  18. achow101 commented at 2:54 PM on September 24, 2022: member

    Yes, for backport

  19. achow101 added the label Needs backport (24.x) on Sep 24, 2022
  20. sidhujag referenced this in commit 9547d5270a on Sep 25, 2022
  21. MarcoFalke removed the label Needs backport (24.x) on Sep 25, 2022
  22. MarcoFalke referenced this in commit ca8d2c4b43 on Sep 25, 2022
  23. fanquake commented at 8:16 AM on September 26, 2022: member

    Backported to 24.x in #26178.

  24. hebasto commented at 9:52 PM on September 27, 2022: member

    Looks like the minimum git to make the merge is 2.33. But the PR itself is fine as-is, and once merged won't be a problem even for old versions of git.

    It appears, it is a problem as now the CI linter job fails.

  25. luke-jr commented at 3:03 AM on September 28, 2022: member

    It appears, it is a problem as now the CI linter job fails.

    ??? Looks like it's working fine to me? https://cirrus-ci.com/build/5775460305993728

  26. hebasto commented at 7:28 AM on September 28, 2022: member

    It appears, it is a problem as now the CI linter job fails.

    ??? Looks like it's working fine to me? https://cirrus-ci.com/build/5775460305993728

    Don't hesitate to look into the following merge commits:

    Merge commit 0cfbb171bd6f61a4edba913e281553b9bdf08d4a is not clean
    
    Merge commit 0cfbb171bd6f61a4edba913e281553b9bdf08d4a is not clean
    
  27. luke-jr commented at 5:36 PM on September 28, 2022: member

    Looks like an issue with verify-commits. Not sure what the best way to fix that is.

  28. MarcoFalke referenced this in commit 291e363ce5 on Sep 29, 2022
  29. bitcoin locked this on Sep 28, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me