aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_libc2.go
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-10-02 15:12:30 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-10-21 10:45:23 -0700
commit8a6c64f4fe726c956ea876cea0fed9494290130f (patch)
tree9f4e8e2385684ec81b94cf2c84e9fd5342e5cfc6 /src/syscall/exec_libc2.go
parent4620db72d273097a1c5fd11e44ce688618559579 (diff)
downloadgo-8a6c64f4fe726c956ea876cea0fed9494290130f.tar.xz
syscall: use rawSyscall6 to call ptrace in forkAndExecInChild
On darwin and openbsd, the autogenerated ptrace wrapper is nosplit because it is called from forkAndExecInChild. This makes it difficult to modify and improve the underlying syscall mechanism, as ptrace is almost over the nosplit limit. We better call ptrace directly using rawSyscall6 in forkAndExecInChild so that we can lift the ptrace nosplit restriction to. Doing so also fixes a long-standing inconsistency: forkAndExecInChild is documented to only allow rawSyscall, but the ptrace wrapper is using non-raw syscalls. Updates #64113 Change-Id: Ibbbb218511561c1a5cb5b6d288a691f9738b14a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/708575 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/syscall/exec_libc2.go')
-rw-r--r--src/syscall/exec_libc2.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/syscall/exec_libc2.go b/src/syscall/exec_libc2.go
index a0579627a3..5de09dfe99 100644
--- a/src/syscall/exec_libc2.go
+++ b/src/syscall/exec_libc2.go
@@ -59,7 +59,6 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
r1 uintptr
nextfd int
i int
- err error
pgrp _C_int
cred *Credential
ngroups, groups uintptr
@@ -99,8 +98,12 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
// Enable tracing if requested.
if sys.Ptrace {
- if err = ptrace(PTRACE_TRACEME, 0, 0, 0); err != nil {
- err1 = err.(Errno)
+ if runtime.GOOS == "ios" {
+ err1 = ENOSYS
+ goto childerror
+ }
+ _, _, err1 = rawSyscall6(abi.FuncPCABI0(libc_ptrace_trampoline), PTRACE_TRACEME, 0, 0, 0, 0, 0)
+ if err1 != 0 {
goto childerror
}
}