]> Cypherpunks repositories - gostls13.git/commit
runtime: fix past-the-end write of wasmStack
authorCherry Zhang <cherryyz@google.com>
Sat, 19 Oct 2019 02:18:27 +0000 (22:18 -0400)
committerCherry Zhang <cherryyz@google.com>
Sat, 19 Oct 2019 04:45:10 +0000 (04:45 +0000)
commite9c994954facb8967f09413d488e875e33fa96ec
treeafd96f8816a630bc3abfacc0f4ddb6d714fd1ed1
parent46aa8354fa57ab5a4fb133898baf18aafbeb2e88
runtime: fix past-the-end write of wasmStack

On Wasm, at program start, we set the SP to
wasmStack+sizeof(wasmStack), and start to write on it. This write
is actually past the end of wasmStack. This may scribble to some
other variable next to it in the data segment. Or if wasmStack
happens to be the last object in the data segment, we'll scribble
to unreserved memory and cause the next sysReserve return
non-zero memory. Either way, this is bad. Fix this by subtracting
16 before writing.

Found while debugging the new page allocator (CL 190622 and the
stack) with Michael. We found that on Wasm, the first sysReserve
may return memory with the first a few words being non-zero.

Change-Id: I2d76dd3fee85bddb2ff6a902b5876dea3f2969a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/202086
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/rt0_js_wasm.s