diff options
author | MacroFake <falke.marco@gmail.com> | 2022-09-24 14:01:56 +0000 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-09-24 14:02:13 +0000 |
commit | 0cfbb171bd6f61a4edba913e281553b9bdf08d4a (patch) | |
tree | 3f7a1240d58ba8041a979121940f5254ac2ab794 | |
parent | 100949af0e2551f22c02a73355f2c64710b68ef1 (diff) | |
parent | a60d9eb9e6b6a272a3fca8981d89a55955dced55 (diff) |
Merge bitcoin/bitcoin#26130: Bugfix: Wallet: Lock cs_wallet for SignMessage
a60d9eb9e6b6a272a3fca8981d89a55955dced55 Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)
Pull request description:
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)
ACKs for top commit:
achow101:
ACK a60d9eb9e6b6a272a3fca8981d89a55955dced55
w0xlt:
ACK https://github.com/bitcoin/bitcoin/pull/26130/commits/a60d9eb9e6b6a272a3fca8981d89a55955dced55
Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
-rw-r--r-- | src/wallet/wallet.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 009c539a65..5889de2e36 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2110,6 +2110,7 @@ SigningResult CWallet::SignMessage(const std::string& message, const PKHash& pkh CScript script_pub_key = GetScriptForDestination(pkhash); for (const auto& spk_man_pair : m_spk_managers) { if (spk_man_pair.second->CanProvide(script_pub_key, sigdata)) { + LOCK(cs_wallet); // DescriptorScriptPubKeyMan calls IsLocked which can lock cs_wallet in a deadlocking order return spk_man_pair.second->SignMessage(message, pkhash, str_sig); } } |