]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: prevent stack growth after fork in runtime.sigfillset
authorHaoran Luo <haoran.luo@chaitin.com>
Tue, 8 Dec 2020 14:29:04 +0000 (14:29 +0000)
committerAustin Clements <austin@google.com>
Wed, 9 Dec 2020 03:01:58 +0000 (03:01 +0000)
This fixes the unexpected growth of stack in child process, which
is caused by stack checking code in runtime.sigfillset called from
runtime.sigset while clearing the signal handlers in child process.

The redundant stack checking code is generated due to missing
'//go:nosplit' directive that should be annotated for
runtime.sigfillset.

Fixes #43066
Updates #21314

Change-Id: I9483a962a4b0747074313991841e2440ee32198c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276173
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/os_linux_be64.go
src/runtime/os_linux_generic.go
src/runtime/os_linux_mips64x.go
src/runtime/os_linux_mipsx.go

index 14fbad5d5f896cae9db5ac9aed3aee116827b043..9860002ee417a9cbe93d34d7f901149239d0407e 100644 (file)
@@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
        *mask &^= 1 << (uint(i) - 1)
 }
 
+//go:nosplit
 func sigfillset(mask *uint64) {
        *mask = ^uint64(0)
 }
index 14810e3cc3b0d2f00bd24080c628ff66ef83c806..e1d0952ddf5abfd0107e894dc67815481be431d2 100644 (file)
@@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
        (*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
 }
 
+//go:nosplit
 func sigfillset(mask *uint64) {
        *mask = ^uint64(0)
 }
index 4ff66f9538a7e71d77e3edec699e65faa710effd..815a83a04bc41432eae97c4df224dc3565d21f4f 100644 (file)
@@ -48,6 +48,7 @@ func sigdelset(mask *sigset, i int) {
        (*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63)
 }
 
+//go:nosplit
 func sigfillset(mask *[2]uint64) {
        (*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0)
 }
index 87962ed982f1c49981baf889fdb9a6e08a92029b..00fb02e4bf5ff6451fe6d698a959b22e49f16a0f 100644 (file)
@@ -42,6 +42,7 @@ func sigdelset(mask *sigset, i int) {
        (*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
 }
 
+//go:nosplit
 func sigfillset(mask *[4]uint32) {
        (*mask)[0], (*mask)[1], (*mask)[2], (*mask)[3] = ^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)
 }