Skip to content

Commit 5784b86

Browse files
randall77pull[bot]
authored andcommitted
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>
1 parent bbac9b3 commit 5784b86

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/runtime/libfuzzer_amd64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ TEXT runtime·libfuzzerCallTraceIntCmp(SB), NOSPLIT, $0-32
9393
MOVQ (g_sched+gobuf_sp)(R10), SP
9494
call:
9595
ANDQ $~15, SP // alignment for gcc ABI
96+
SUBQ $8, SP
9697
// Load the address of the end of the function and push it into the stack.
9798
// This address will be jumped to after executing the return instruction
9899
// from the return sled. There we reset the stack pointer and return.

0 commit comments

Comments
 (0)