aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/syscall_aix.go
diff options
context:
space:
mode:
authorDmitri Goutnik <dgoutnik@gmail.com>2023-02-22 10:58:14 -0500
committerGopher Robot <gobot@golang.org>2023-02-23 11:28:51 +0000
commit4c5d6edeb2b10c2044d1ea2b4fa3e403133431c8 (patch)
treef3dc2e918e672753257a3b98da2e7d95d23df74a /src/syscall/syscall_aix.go
parent6af9635fb8a002f563a1765f7ab2bd97d4e4d4df (diff)
downloadgo-4c5d6edeb2b10c2044d1ea2b4fa3e403133431c8.tar.xz
syscall: add ptracePtr that accepts pointer arg as unsafe.Pointer
The existing ptrace wrapper accepts pointer argument as an uintptr which often points to the memory allocated in Go. This violates unsafe.Pointer safety rules. Fixes #58387 Change-Id: Iab12122c495953f94ea00c2a61654a818a464205 Reviewed-on: https://go-review.googlesource.com/c/go/+/470299 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Dmitri Goutnik <dgoutnik@gmail.com>
Diffstat (limited to 'src/syscall/syscall_aix.go')
-rw-r--r--src/syscall/syscall_aix.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go
index 807990f3c0..ba1b50e0fc 100644
--- a/src/syscall/syscall_aix.go
+++ b/src/syscall/syscall_aix.go
@@ -505,6 +505,7 @@ func (w WaitStatus) TrapCause() int { return -1 }
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
//sys ptrace64(request int, id int64, addr int64, data int, buff uintptr) (err error)
+//sys ptrace64Ptr(request int, id int64, addr int64, data int, buff unsafe.Pointer) (err error) = ptrace64
func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
if request == PTRACE_TRACEME {
@@ -525,7 +526,7 @@ func ptracePeek(pid int, addr uintptr, out []byte) (count int, err error) {
if bsize > 1024 {
bsize = 1024
}
- err = ptrace64(PT_READ_BLOCK, int64(pid), int64(addr), bsize, uintptr(unsafe.Pointer(&out[0])))
+ err = ptrace64Ptr(PT_READ_BLOCK, int64(pid), int64(addr), bsize, unsafe.Pointer(&out[0]))
if err != nil {
return 0, err
}
@@ -551,7 +552,7 @@ func ptracePoke(pid int, addr uintptr, data []byte) (count int, err error) {
if bsize > 1024 {
bsize = 1024
}
- err = ptrace64(PT_WRITE_BLOCK, int64(pid), int64(addr), bsize, uintptr(unsafe.Pointer(&data[0])))
+ err = ptrace64Ptr(PT_WRITE_BLOCK, int64(pid), int64(addr), bsize, unsafe.Pointer(&data[0]))
if err != nil {
return 0, err
}