Skip to content

Commit

Permalink
salsa20/salsa: fix amd64 assembly not to smash SP
Browse files Browse the repository at this point in the history
**salsa20 is used by V1 protocol of DNSCrypt**
golang/go#44269
quote:
x/crypto/*.s masks and writes to SP during function execution.
This is not allowed by the Go ABI. All SP modifications on goroutine stacks must be constant additions or subtractions, or else the garbage collector cannot unwind the stack from that location.

Code used to get away with this due to cooperative scheduling, but now that we scan stacks preemptively, it is especially important that functions not do this.

New code in Go 1.17 will stop stack traces in such functions, which will make programs crash more loudly. But they are still broken in earlier versions and may just cause silent memory corruption instead of loud crashes.

hashBlocksSSE2 and hashBlocksSSSE3 should leave SP alone.
  • Loading branch information
AZ-X committed Feb 20, 2021
1 parent 3a7d6c4 commit 9e9751d
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 123 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -8,7 +8,7 @@ require (
github.com/jedisct1/dlog v0.0.0-20190909160351-692385b00b84
github.com/jedisct1/go-clocksmith v0.0.0-20190707124905-73e087c7979c
github.com/miekg/dns v1.1.35
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
gopkg.in/natefinch/lumberjack.v2 v2.0.0
stammel v0.0.0-00010101000000-000000000000
Expand Down
3 changes: 2 additions & 1 deletion vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e9751d

Please sign in to comment.