]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix possible spill of invalid pointer with DUFFZERO on AMD64
authorCherry Zhang <cherryyz@google.com>
Thu, 28 Jul 2016 16:22:49 +0000 (12:22 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 29 Jul 2016 01:09:55 +0000 (01:09 +0000)
commit111d590f86e2c9a55ec08d95fc4e9adea9232f0c
tree33ecd79346a93650ce3082128f4091e9527b0679
parentbe915159073ed93fa511ceef7256bc8ee396d1c7
cmd/compile: fix possible spill of invalid pointer with DUFFZERO on AMD64

SSA compiler on AMD64 may spill Duff-adjusted address as scalar. If
the object is on stack and the stack moves, the spilled address become
invalid.

Making the spill pointer-typed does not work. The Duff-adjusted address
points to the memory before the area to be zeroed and may be invalid.
This may cause stack scanning code panic.

Fix it by doing Duff-adjustment in genValue, so the intermediate value
is not seen by the reg allocator, and will not be spilled.

Add a test to cover both cases. As it depends on allocation, it may
be not always triggered.

Fixes #16515.

Change-Id: Ia81d60204782de7405b7046165ad063384ede0db
Reviewed-on: https://go-review.googlesource.com/25309
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/AMD64Ops.go
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
test/fixedbugs/issue16515.go [new file with mode: 0644]