-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Description
Go version
go version go1.25.1 linux/amd64
Output of go env in your module/workspace:
go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/rkerno/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/rkerno/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4067861915=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/rkerno/src/m/golib/go.mod'
GOMODCACHE='/home/rkerno/go/pkg/mod'
GONOPROXY='gitlab.projectcatalysts.prv'
GONOSUMDB='gitlab.projectcatalysts.prv'
GOOS='linux'
GOPATH='/home/rkerno/go'
GOPRIVATE='gitlab.projectcatalysts.prv'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/rkerno/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK='/home/rkerno/src/m/go.work'
PKG_CONFIG='pkg-config'
uname -sr: Linux 6.6.87.2-microsoft-standard-WSL2
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.31-13+deb11u7) stable release version 2.31.What did you do?
After creating an ed25519.PrivateKey ([]byte) from memory backed by a guarded memory page under my control (not part of Go's memory allocations), ed25519.Sign() panics because the pointer in the slice is not allocated by go.
This is a issue that was introduced after version 1.23.1 (I've just upgraded my project).
This is the function that panics:
//go:linkname internal_weak_runtime_registerWeakPointer weak.runtime_registerWeakPointer
func internal_weak_runtime_registerWeakPointer(p unsafe.Pointer) unsafe.Pointer {
return unsafe.Pointer(getOrAddWeakHandle(unsafe.Pointer(p)))
}
If I hold my cursor over the variable p, this message is reported:
(unreadable could not find loclist entry at 0x2d2d1 for address 0x483bb3)
The issue is caused by the use of the fips140 private key cache:
func sign(signature []byte, privateKey PrivateKey, message []byte) {
k, err := privateKeyCache.Get(&privateKey[0], func() (*ed25519.PrivateKey, error) {
The reason for using a guarded page is so that I have explicit control over the lifetime of the private key, can prevent it from being included in crash dumps, and can ensure the backing memory is scrubbed when the key is no longer required. Introducing an (undocumented) requirement that the private key must be backed by go controlled memory is a regression,
What did you see happen?
fatal error: getWeakHandle on invalid pointer
goroutine 6 gp=0xc0001a2380 m=4 mp=0xc00004f808 [running]:
runtime.throw({0x88d1e1?, 0x498497?})
/usr/local/go/src/runtime/panic.go:1094 +0x48 fp=0xc0001bea80 sp=0xc0001bea50 pc=0x484b48
runtime.getWeakHandle(0x750d2c4f0040)
/usr/local/go/src/runtime/mheap.go:2639 +0xf2 fp=0xc0001bead0 sp=0xc0001bea80 pc=0x43a9d2
runtime.getOrAddWeakHandle(0x750d2c4f0040)
/usr/local/go/src/runtime/mheap.go:2568 +0x2b fp=0xc0001beb20 sp=0xc0001bead0 pc=0x43a76b
weak.runtime_registerWeakPointer(0x8b7430?)
/usr/local/go/src/runtime/mheap.go:2451 +0x13 fp=0xc0001beb38 sp=0xc0001beb20 pc=0x483bb3
weak.Make...
/usr/local/go/src/weak/pointer.go:74 +0x65 fp=0xc0001beb88 sp=0xc0001beb38 pc=0x63e9a5
crypto/internal/fips140cache.(*Cache[...]).Get(0x8bce80, 0x750d2c4f0040, 0xc0001bed88, 0xc0001bed68)
/usr/local/go/src/crypto/internal/fips140cache/cache.go:33 +0x76 fp=0xc0001bed00 sp=0xc0001beb88 pc=0x63de36
crypto/ed25519.sign({0xc0000ba040, 0x40, 0x40}, {0x750d2c4f0040, 0x40, 0x40}, {0xc0001bf847, 0x19, 0x19})
/usr/local/go/src/crypto/ed25519/ed25519.go:189 +0x173 fp=0xc0001bee58 sp=0xc0001bed00 pc=0x63d393
crypto/ed25519.Sign({0x750d2c4f0040, 0x40, 0x40}, {0xc0001bf847, 0x19, 0x19})
/usr/local/go/src/crypto/ed25519/ed25519.go:184 +0xde fp=0xc0001beef8 sp=0xc0001bee58 pc=0x63d19ec
What did you expect to see?
This call worked in 1.23.1.