diff options
| author | Austin Clements <austin@google.com> | 2017-12-03 19:28:28 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-02-15 21:12:11 +0000 |
| commit | b1d94c118fd163381537a22be4913742103baece (patch) | |
| tree | 04aeca443a621a3cecf8a8e990c3015007d92b53 /src/runtime/lfstack.go | |
| parent | 981d0495b7ed6e1a5fb0fba818bdc2bf9d4b13fa (diff) | |
| download | go-b1d94c118fd163381537a22be4913742103baece.tar.xz | |
runtime: validate lfnode addresses
Change-Id: Ic8c506289caaf6218494e5150d10002e0232feaa
Reviewed-on: https://go-review.googlesource.com/85876
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/lfstack.go')
| -rw-r--r-- | src/runtime/lfstack.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/lfstack.go b/src/runtime/lfstack.go index 4787c5be3f..406561a275 100644 --- a/src/runtime/lfstack.go +++ b/src/runtime/lfstack.go @@ -55,3 +55,13 @@ func (head *lfstack) pop() unsafe.Pointer { func (head *lfstack) empty() bool { return atomic.Load64((*uint64)(head)) == 0 } + +// lfnodeValidate panics if node is not a valid address for use with +// lfstack.push. This only needs to be called when node is allocated. +func lfnodeValidate(node *lfnode) { + if lfstackUnpack(lfstackPack(node, ^uintptr(0))) != node { + printlock() + println("runtime: bad lfnode address", hex(uintptr(unsafe.Pointer(node)))) + throw("bad lfnode address") + } +} |
