]> Cypherpunks repositories - gostls13.git/commit
runtime: keep track of secret allocation size
authorDaniel Morsing <daniel.morsing@gmail.com>
Tue, 16 Dec 2025 13:50:57 +0000 (13:50 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 17 Dec 2025 21:04:25 +0000 (13:04 -0800)
commitb8c4cc63e77bd457dffa6ec83a3ff65382dac94b
tree9cc9be8cbcdc55f5e1cd0aa0eea8f6db7091aa48
parent8564fede8929df5bbf9f10d35ff9d3620683ca80
runtime: keep track of secret allocation size

During a naive attempt to test the new runtime/secret package, I tried
wrapping the entire handshake in a secret.Do call. This lead to a panic
because some of the allocator logic had been previously untested.

freeSpecial takes p and size, but they can be misleading. They don't
refer to the pointer and size of the object with the special attached,
but a pointer to the enclosing object and the size of the span element.

The previous code did not take this into account and when passing the
size to memclr would overwrite nearby objects.

Fix by storing the size of the object being cleared inside the special.

Fixes #76865.

Change-Id: Ifae31f1c8d0609a562a37f37c45aec2f369dc6a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/730361
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
src/runtime/malloc.go
src/runtime/malloc_generated.go
src/runtime/malloc_stubs.go
src/runtime/mheap.go
src/runtime/secret.go
src/runtime/secret/alloc_test.go [new file with mode: 0644]
src/runtime/secret_nosecret.go