]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: support libFuzzer value profiling mode for integer compares
authorKhaled Yakdan <yakdan@code-intelligence.com>
Mon, 23 May 2022 15:04:25 +0000 (15:04 +0000)
committerKeith Randall <khr@golang.org>
Mon, 23 May 2022 16:21:22 +0000 (16:21 +0000)
commitc1d197a96e3b3ed6ce585a5e6115586c85de0363
treead789aa3fce3d0cc6bdfc6b342fb82071a39e952
parent3f571d1dea775417a171c17632ac3c1fbc84b0fd
cmd/compile: support libFuzzer value profiling mode for integer compares

libFuzzer provides a special mode known as “value profiling” in which it
tracks the bit-wise progress made by the fuzzer in satisfying tracked
comparisons. Furthermore, libFuzzer uses the value of the return address
in its hooks to distinguish the progress for different comparisons.

The original implementation of the interception for integer comparisons
in Go simply called the libFuzzer hooks from a function written in Go
assembly. The libFuzzer hooks thus always see the same return address
(i.e., the address of the call instruction in the assembly snippet) and
thus can’t distinguish individual comparisons anymore. This drastically
reduces the usefulness of value profiling.

This is fixed by using an assembly trampoline that injects synthetic but
valid return addresses on the stack before calling the libFuzzer hook,
otherwise preserving the calling convention of the respective platform
(for starters, x86_64 Windows or Unix). These fake PCs are generated
deterministically based on the location of the compare instruction in
the IR representation.

Change-Id: Iea68057c83aea7f9dc226fba7128708e8637d07a
GitHub-Last-Rev: f9184baafd507eb4c31f7d99b3894595689d8f89
GitHub-Pull-Request: golang/go#51321
Reviewed-on: https://go-review.googlesource.com/c/go/+/387336
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/typecheck/builtin.go
src/cmd/compile/internal/typecheck/builtin/runtime.go
src/cmd/compile/internal/walk/compare.go
src/internal/fuzz/trace.go
src/runtime/libfuzzer.go
src/runtime/libfuzzer_amd64.s
src/runtime/libfuzzer_arm64.s