From: Keith Randall Date: Tue, 9 May 2023 22:55:45 +0000 (-0700) Subject: runtime: fix misaligned SP for libfuzzer entry X-Git-Tag: go1.21rc1~621 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5d76600cc01790c0eed9d0e2783ecf5bc7957993;p=gostls13.git 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 TryBot-Result: Gopher Robot Run-TryBot: Keith Randall Reviewed-by: Keith Randall --- 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.