Skip to content

Commit 4527acd

Browse files
committed
Unpoison MSan signatures
After schnorr signing mark the signature buffer initialized under MemorySanitizer because libsecp256k1 isn’t instrumented and MSan would otherwise flag the certificate copy as uninitialized. Assisted-by: GitHub Copilot Assisted-by: OpenAI GPT-5-Codex
1 parent 1922c1e commit 4527acd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sv2/noise.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <crypto/chacha20poly1305.h>
88
#include <crypto/hmac_sha256.h>
99
#include <logging.h>
10+
#ifdef MEMORY_SANITIZER
11+
#include <sanitizer/msan_interface.h>
12+
#endif
1013
#include <util/check.h>
1114
#include <util/strencodings.h>
1215
#include <util/time.h>
@@ -60,6 +63,9 @@ bool Sv2SignatureNoiseMessage::Validate(XOnlyPubKey authority_key)
6063
void Sv2SignatureNoiseMessage::SignSchnorr(const CKey& authority_key, std::span<unsigned char> sig)
6164
{
6265
authority_key.SignSchnorr(this->GetHash(), sig, nullptr, {});
66+
#ifdef MEMORY_SANITIZER
67+
__msan_unpoison(sig.data(), sig.size());
68+
#endif
6369
}
6470

6571
Sv2CipherState::Sv2CipherState(NoiseHash&& key) : m_key(std::move(key)) {};

0 commit comments

Comments
 (0)