Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: permission denied #19

Open
pherzheyu opened this issue Apr 19, 2022 · 4 comments
Open

panic: permission denied #19

pherzheyu opened this issue Apr 19, 2022 · 4 comments

Comments

@pherzheyu
Copy link

image
panic: permission denied [recovered]
panic: permission denied

goroutine 162 [running]:
testing.tRunner.func1.2({0x4b819e0, 0x55a90a8})
/usr/local/go/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1212 +0x218
panic({0x4b819e0, 0x55a90a8})
/usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/cch123/supermonkey/internal/bouk.mprotectCrossPage(0x461f6e0, 0xc, 0x10)
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/internal/bouk/replace_unix.go:15 +0xc5
github.com/cch123/supermonkey/internal/bouk.CopyToLocation(0x461f6e0, {0xc000651cc4, 0xc, 0xc000384108})
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/internal/bouk/replace_unix.go:26 +0x5c
github.com/cch123/supermonkey/internal/bouk.ReplaceFunction(0x461f6e0, 0x4cf9f08)
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/internal/bouk/replace.go:29 +0xb2
github.com/cch123/supermonkey/internal/bouk.patchValue({0x4b4e800, 0x4cf9f08, 0x0}, {0x4b4e800, 0x4cf9c18, 0x13}, 0x0)
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/internal/bouk/monkey.go:96 +0x2b6
github.com/cch123/supermonkey/internal/bouk.Patch({0x4b4e800, 0x4cf9f08}, {0x4b4e800, 0x4cf9c18})
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/internal/bouk/monkey.go:50 +0x17a
github.com/cch123/supermonkey.Patch({0x4b4e800, 0x4cf9f08}, {0x4b4e800, 0x4cf9c18})
/Users/sangtianyu/go/pkg/mod/github.com/cch123/[email protected]/supermonkey.go:23 +0x2d

go env
GO111MODULE="on"
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"

@cch123
Copy link
Owner

cch123 commented May 17, 2022

may you provide a demo to reproduce this panic?

@ma642
Copy link

ma642 commented Aug 11, 2022

same error got. when patch

@ma642
Copy link

ma642 commented Aug 11, 2022

reproduce code:

package main

import _ "github.com/google/gopacket/pcap"

func main() {
patchFunc()
patchFuncSymbol()

patchInstanceFunc()
patchInstanceFuncSymbol()

patchStructMethod()
patchStructMethodSymbol()

}

@Marakai
Copy link

Marakai commented Oct 24, 2022

I suspect the issue the same one discussed elsewhere on this issue on M1 Macs.

In replace_unix.go

err := syscall.Mprotect(page, prot)
		if err != nil {
			panic(err)
		}

fails on Apple silicon. Diving through threads, first this seemed to be a bug, but now Apple says this is working as intended and you're supposed to use pthread_jit_write_protect_np as per

https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon?language=objc

Alas, I have no idea how you would call that in Go, barring using C extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants