diff options
| author | Austin Clements <austin@google.com> | 2019-12-02 17:36:25 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2019-12-05 01:48:14 +0000 |
| commit | 8174f7fb2b64c221f7f80c9f7fd4d7eb317ac8bb (patch) | |
| tree | 14e617cf022bfc197221468d24c1a66bed6c193c /src/runtime/os_linux.go | |
| parent | fa3a121a79f85a4c957f29372b5ebfde7211a980 (diff) | |
| download | go-8174f7fb2b64c221f7f80c9f7fd4d7eb317ac8bb.tar.xz | |
runtime: mlock top of signal stack on Linux 5.2–5.4.1
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 <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 27c66f7449..1eb86e9c8b 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -289,6 +289,7 @@ func getHugePageSize() uintptr { func osinit() { ncpu = getproccount() physHugePageSize = getHugePageSize() + osArchInit() } var urandom_dev = []byte("/dev/urandom\x00") @@ -318,11 +319,20 @@ func libpreinit() { initsig(true) } +// gsignalInitQuirk, if non-nil, is called for every allocated gsignal G. +// +// TODO(austin): Remove this after Go 1.15 when we remove the +// mlockGsignal workaround. +var gsignalInitQuirk func(gsignal *g) + // Called to initialize a new m (including the bootstrap m). // Called on the parent thread (main thread in case of bootstrap), can allocate memory. func mpreinit(mp *m) { mp.gsignal = malg(32 * 1024) // Linux wants >= 2K mp.gsignal.m = mp + if gsignalInitQuirk != nil { + gsignalInitQuirk(mp.gsignal) + } } func gettid() uint32 |
