Skip to content

Commit 7d4f86d

Browse files
committed
Merge bitcoin-core/secp256k1#1307: Mark more assembly outputs as early clobber
8c9ae37 Add release note (Pieter Wuille) 350b4bd Mark stack variables as early clobber for technical correctness (Pieter Wuille) 0c729ba Bugfix: mark outputs as early clobber in scalar x86_64 asm (Pieter Wuille) Pull request description: ACKs for top commit: real-or-random: ACK 8c9ae37 jonasnick: ACK 8c9ae37 Tree-SHA512: 874d01f5540d14b5188aec25f6441dbc6631f8d3980416040a3e250f1aef75150068415e7a458a9a3fb0d7cbdeb97f5c7e089b187d6d3dd79aa6e45274c241b6
2 parents b54a067 + 8c9ae37 commit 7d4f86d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
#### Fixed
11+
- Fixed an old bug that permitted compilers to potentially output bad assembly code on x86_64. In theory, it could lead to a crash or a read of unrelated memory, but this has never been observed on any compilers so far.
12+
1013
## [0.3.1] - 2023-04-10
1114
We strongly recommend updating to 0.3.1 if you use or plan to use Clang >=14 to compile libsecp256k1, e.g., Xcode >=14 on macOS has Clang >=14. When in doubt, check the Clang version using `clang -v`.
1215

src/field_5x52_asm_impl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ __asm__ __volatile__(
280280
"addq %%rsi,%%r8\n"
281281
/* r[4] = c */
282282
"movq %%r8,32(%%rdi)\n"
283-
: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3)
283+
: "+S"(a), "=&m"(tmp1), "=&m"(tmp2), "=&m"(tmp3)
284284
: "b"(b), "D"(r)
285285
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory"
286286
);
@@ -495,7 +495,7 @@ __asm__ __volatile__(
495495
"addq %%rsi,%%r8\n"
496496
/* r[4] = c */
497497
"movq %%r8,32(%%rdi)\n"
498-
: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3)
498+
: "+S"(a), "=&m"(tmp1), "=&m"(tmp2), "=&m"(tmp3)
499499
: "D"(r)
500500
: "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory"
501501
);

src/scalar_4x64_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint64_t *l)
383383
"movq %%r10, %q5\n"
384384
/* extract m6 */
385385
"movq %%r8, %q6\n"
386-
: "=g"(m0), "=g"(m1), "=g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6)
386+
: "=&g"(m0), "=&g"(m1), "=&g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6)
387387
: "S"(l), "i"(SECP256K1_N_C_0), "i"(SECP256K1_N_C_1)
388388
: "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc");
389389

0 commit comments

Comments
 (0)