mirror of
https://github.com/golang/go
synced 2024-11-19 10:04:56 -07:00
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>
This commit is contained in:
parent
981d0495b7
commit
b1d94c118f
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -400,6 +400,7 @@ func getempty() *workbuf {
|
||||
for i := uintptr(0); i+_WorkbufSize <= workbufAlloc; i += _WorkbufSize {
|
||||
newb := (*workbuf)(unsafe.Pointer(s.base() + i))
|
||||
newb.nobj = 0
|
||||
lfnodeValidate(&newb.node)
|
||||
if i == 0 {
|
||||
b = newb
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user