diff options
| author | cions <gh.cions@gmail.com> | 2024-09-24 01:27:40 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-09-26 13:17:09 +0000 |
| commit | a3a05ed04cb53c53bdacded2d16f0f3e5facdbb0 (patch) | |
| tree | 71444f68912290bd3a092dd011bb80db04d23b8e /src/os | |
| parent | 607975cfa15768e3587facfbde18ef9f18c46170 (diff) | |
| download | go-a3a05ed04cb53c53bdacded2d16f0f3e5facdbb0.tar.xz | |
os: ignore SIGSYS in checkPidfd
In Android version 11 and earlier, pidfd-related system calls
are not allowed by the seccomp policy, which causes crashes due
to SIGSYS signals.
Fixes #69065
Change-Id: Ib29631639a5cf221ac11b4d82390cb79436b8657
GitHub-Last-Rev: aad6b3b32c81795f86bc4a9e81aad94899daf520
GitHub-Pull-Request: golang/go#69543
Reviewed-on: https://go-review.googlesource.com/c/go/+/614277
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/pidfd_linux.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/os/pidfd_linux.go b/src/os/pidfd_linux.go index 459d88cb44..0bfef7759c 100644 --- a/src/os/pidfd_linux.go +++ b/src/os/pidfd_linux.go @@ -18,6 +18,7 @@ package os import ( "errors" "internal/syscall/unix" + "runtime" "sync" "syscall" "unsafe" @@ -151,6 +152,13 @@ var checkPidfdOnce = sync.OnceValue(checkPidfd) // execution environment in which the above system calls are restricted by // seccomp or a similar technology. func checkPidfd() error { + // In Android version < 12, pidfd-related system calls are not allowed + // by seccomp and trigger the SIGSYS signal. See issue #69065. + if runtime.GOOS == "android" { + ignoreSIGSYS() + defer restoreSIGSYS() + } + // Get a pidfd of the current process (opening of "/proc/self" won't // work for waitid). fd, err := unix.PidFDOpen(syscall.Getpid(), 0) @@ -192,3 +200,11 @@ func checkPidfd() error { // //go:linkname checkClonePidfd func checkClonePidfd() error + +// Provided by runtime. +// +//go:linkname ignoreSIGSYS +func ignoreSIGSYS() + +//go:linkname restoreSIGSYS +func restoreSIGSYS() |
