]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add spectre mitigation mode enabled by -spectre
authorRuss Cox <rsc@golang.org>
Mon, 6 Jan 2020 15:31:39 +0000 (10:31 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 13 Mar 2020 19:05:46 +0000 (19:05 +0000)
commit877ef86bec593cd7e40899ac5446791e65b47839
tree1889b71db027e147f6b2aef734c928ff572a4d95
parentd84cbec8908a04aa56889919942a3210963abaef
cmd/compile: add spectre mitigation mode enabled by -spectre

This commit adds a new cmd/compile flag -spectre,
which accepts a comma-separated list of possible
Spectre mitigations to apply, or the empty string (none),
or "all". The only known mitigation right now is "index",
which uses conditional moves to ensure that x86-64 CPUs
do not speculate past index bounds checks.

Speculating past index bounds checks may be problematic
on systems running privileged servers that accept requests
from untrusted users who can execute their own programs
on the same machine. (And some more constraints that
make it even more unlikely in practice.)

The cases this protects against are analogous to the ones
Microsoft explains in the "Array out of bounds load/store feeding ..."
sections here:
https://docs.microsoft.com/en-us/cpp/security/developer-guidance-speculative-execution?view=vs-2019#array-out-of-bounds-load-feeding-an-indirect-branch

Change-Id: Ib7532d7e12466b17e04c4e2075c2a456dc98f610
Reviewed-on: https://go-review.googlesource.com/c/go/+/222660
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
test/codegen/spectre.go [new file with mode: 0644]