aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-05-09 15:55:45 -0700
committerKeith Randall <khr@golang.org>2023-05-10 04:57:07 +0000
commit5d76600cc01790c0eed9d0e2783ecf5bc7957993 (patch)
tree16bef397f641a25043bcdc3eea038e1ed4ee1cd4
parentaa4d5e739f32397969fd5c33cbc95d316686039f (diff)
downloadgo-5d76600cc01790c0eed9d0e2783ecf5bc7957993.tar.xz
runtime: fix misaligned SP for libfuzzer entry
libfuzzer is written in C and so requires by the C abi that SP be aligned correctly mod 16. Normally CALLs need to have SP aligned to 0 mod 16, but because we're simulating a CALL (which pushes a return address) with a JMP (which doesn't), we need to align to 8 mod 16 before JMPing. This is not causing any current problems that I know of. All the functions called from this callsite that I checked don't rely on correct alignment. So this CL is just futureproofing. Update #49075 Change-Id: I13fcbe9aaf2853056a6d44dc3aa64b7db689e144 Reviewed-on: https://go-review.googlesource.com/c/go/+/494117 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
-rw-r--r--src/runtime/libfuzzer_amd64.s1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/libfuzzer_amd64.s b/src/runtime/libfuzzer_amd64.s
index 7f184d9cb6..e30b768a05 100644
--- a/src/runtime/libfuzzer_amd64.s
+++ b/src/runtime/libfuzzer_amd64.s
@@ -93,6 +93,7 @@ TEXT runtime·libfuzzerCallTraceIntCmp(SB), NOSPLIT, $0-32
MOVQ (g_sched+gobuf_sp)(R10), SP
call:
ANDQ $~15, SP // alignment for gcc ABI
+ SUBQ $8, SP
// Load the address of the end of the function and push it into the stack.
// This address will be jumped to after executing the return instruction
// from the return sled. There we reset the stack pointer and return.