aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2022-12-20 11:25:38 -0500
committerMichael Pratt <mpratt@google.com>2022-12-21 17:14:34 +0000
commit58f6022eee95f43b4e0dc640b012bb3f574898f1 (patch)
treea25ca09d54a4e91826ae7bf325d4e47c73113eb6
parent78fc81070a853d08a71f70fa20b2093f5535e6c5 (diff)
downloadgo-58f6022eee95f43b4e0dc640b012bb3f574898f1.tar.gz
go-58f6022eee95f43b4e0dc640b012bb3f574898f1.zip
syscall: don't use faccessat2 on android
The Android seccomp policy does not allow faccessat2, so attempting to use it results in a SIGSYS. Avoid it and go straight to the fallback. Fixes #57393. Change-Id: I8d4e12a6f46cea5642d3b5b5a02c682529882f29 Reviewed-on: https://go-review.googlesource.com/c/go/+/458495 Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Changkun Ou <mail@changkun.de> Run-TryBot: Michael Pratt <mpratt@google.com>
-rw-r--r--src/syscall/syscall_linux.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
index 30fa641627..d4cc34bdee 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
@@ -13,6 +13,7 @@ package syscall
import (
"internal/itoa"
+ "runtime"
"unsafe"
)
@@ -145,8 +146,17 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
return faccessat(dirfd, path, mode)
}
- if err := faccessat2(dirfd, path, mode, flags); err != ENOSYS && err != EPERM {
- return err
+ // Attempt to use the newer faccessat2, which supports flags directly,
+ // falling back if it doesn't exist.
+ //
+ // Don't attempt on Android, which does not allow faccessat2 through
+ // its seccomp policy [1] on any version of Android as of 2022-12-20.
+ //
+ // [1] https://cs.android.com/android/platform/superproject/+/master:bionic/libc/SECCOMP_BLOCKLIST_APP.TXT;l=4;drc=dbb8670dfdcc677f7e3b9262e93800fa14c4e417
+ if runtime.GOOS != "android" {
+ if err := faccessat2(dirfd, path, mode, flags); err != ENOSYS && err != EPERM {
+ return err
+ }
}
// The Linux kernel faccessat system call does not take any flags.