diff options
author | Andrei Vagin <avagin@google.com> | 2020-09-29 04:45:55 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-09-30 05:39:59 +0000 |
commit | 3caaaddffd605c0ec1787d68295b732fff73026b (patch) | |
tree | 3ecc32886e68d2a6b108476a184c72ff84e0e1e2 /src/syscall | |
parent | 0e85fd7561de869add933801c531bf25dee9561c (diff) | |
download | go-3caaaddffd605c0ec1787d68295b732fff73026b.tar.gz go-3caaaddffd605c0ec1787d68295b732fff73026b.zip |
runtime: don't crash if vsyscall and vdso are disabled on x86_64
If vdso is disabled, the goruntime calls gettimeofday from vsyscall,
but if vsyscall is disabled too, all golang binaries crash:
SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffffffffff600000} ---
killed by SIGSEGV (core dumped) ++
vsyscall doesn't work as it was designed for a long time due to security
reasons and now vsyscall is a little more expensive than real syscalls:
https://github.com/torvalds/linux/commit/5cec93c216db
This patch reworks the code to call syscalls if the vdso library isn't
available.
Change-Id: I16cbf3f49871bea91e26af1f49aa0ae2fbd3a01d
GitHub-Last-Rev: 1d133cd30a5dee1fea9aee0fb4ea0b07e0e87f2a
GitHub-Pull-Request: golang/go#41681
Reviewed-on: https://go-review.googlesource.com/c/go/+/257982
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/syscall')
-rw-r--r-- | src/syscall/asm_linux_amd64.s | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/syscall/asm_linux_amd64.s b/src/syscall/asm_linux_amd64.s index 2c3374338f..ba22179dc2 100644 --- a/src/syscall/asm_linux_amd64.s +++ b/src/syscall/asm_linux_amd64.s @@ -9,6 +9,8 @@ // System calls for AMD64, Linux // +#define SYS_gettimeofday 96 + // func Syscall(trap int64, a1, a2, a3 uintptr) (r1, r2, err uintptr); // Trap # in AX, args in DI SI DX R10 R8 R9, return in AX DX // Note that this differs from "standard" ABI convention, which @@ -144,13 +146,19 @@ TEXT ·gettimeofday(SB),NOSPLIT,$0-16 MOVQ tv+0(FP), DI MOVQ $0, SI MOVQ runtime·vdsoGettimeofdaySym(SB), AX + TESTQ AX, AX + JZ fallback CALL AX - +ret: CMPQ AX, $0xfffffffffffff001 JLS ok7 NEGQ AX MOVQ AX, err+8(FP) RET +fallback: + MOVL $SYS_gettimeofday, AX + SYSCALL + JMP ret ok7: MOVQ $0, err+8(FP) RET |