From 8174f7fb2b64c221f7f80c9f7fd4d7eb317ac8bb Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 2 Dec 2019 17:36:25 -0500 Subject: runtime: mlock top of signal stack on Linux 5.2–5.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux 5.2 introduced a bug that can corrupt vector registers on return from a signal if the signal stack isn't faulted in: https://bugzilla.kernel.org/show_bug.cgi?id=205663 This CL works around this by mlocking the top page of all Go signal stacks on the affected kernels. Fixes #35326, #35777 Change-Id: I77c80a2baa4780827633f92f464486caa222295d Reviewed-on: https://go-review.googlesource.com/c/go/+/209899 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang Reviewed-by: Ian Lance Taylor Reviewed-by: David Chase --- src/runtime/sys_linux_amd64.s | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/runtime/sys_linux_amd64.s') diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index d16060f6fa..174120f887 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -33,8 +33,10 @@ #define SYS_clone 56 #define SYS_exit 60 #define SYS_kill 62 +#define SYS_uname 63 #define SYS_fcntl 72 #define SYS_sigaltstack 131 +#define SYS_mlock 149 #define SYS_arch_prctl 158 #define SYS_gettid 186 #define SYS_futex 202 @@ -764,3 +766,20 @@ TEXT runtime·sbrk0(SB),NOSPLIT,$0-8 SYSCALL MOVQ AX, ret+0(FP) RET + +// func uname(utsname *new_utsname) int +TEXT ·uname(SB),NOSPLIT,$0-16 + MOVQ utsname+0(FP), DI + MOVL $SYS_uname, AX + SYSCALL + MOVQ AX, ret+8(FP) + RET + +// func mlock(addr, len uintptr) int +TEXT ·mlock(SB),NOSPLIT,$0-24 + MOVQ addr+0(FP), DI + MOVQ len+8(FP), SI + MOVL $SYS_mlock, AX + SYSCALL + MOVQ AX, ret+16(FP) + RET -- cgit v1.3