1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:00:07 -07:00

runtime: prevent stack growth after fork in runtime.sigfillset

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>
This commit is contained in:
Haoran Luo 2020-12-08 14:29:04 +00:00 committed by Austin Clements
parent ae9b442df2
commit 6fa06d960b
4 changed files with 4 additions and 0 deletions

View File

@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
*mask &^= 1 << (uint(i) - 1) *mask &^= 1 << (uint(i) - 1)
} }
//go:nosplit
func sigfillset(mask *uint64) { func sigfillset(mask *uint64) {
*mask = ^uint64(0) *mask = ^uint64(0)
} }

View File

@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
(*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31) (*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
} }
//go:nosplit
func sigfillset(mask *uint64) { func sigfillset(mask *uint64) {
*mask = ^uint64(0) *mask = ^uint64(0)
} }

View File

@ -48,6 +48,7 @@ func sigdelset(mask *sigset, i int) {
(*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63) (*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63)
} }
//go:nosplit
func sigfillset(mask *[2]uint64) { func sigfillset(mask *[2]uint64) {
(*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0) (*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0)
} }

View File

@ -42,6 +42,7 @@ func sigdelset(mask *sigset, i int) {
(*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31) (*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
} }
//go:nosplit
func sigfillset(mask *[4]uint32) { func sigfillset(mask *[4]uint32) {
(*mask)[0], (*mask)[1], (*mask)[2], (*mask)[3] = ^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0) (*mask)[0], (*mask)[1], (*mask)[2], (*mask)[3] = ^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)
} }