Skip to content

Unexpected Behavior After Calling ptrace TRACEME #35811

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

Closed
bubundas17 opened this issue Nov 24, 2019 · 1 comment
Closed

Unexpected Behavior After Calling ptrace TRACEME #35811

bubundas17 opened this issue Nov 24, 2019 · 1 comment

Comments

@bubundas17
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.13 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bubun/snap/code/common/.cache/go-build"
GOENV="/home/bubun/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/bubun/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build673698735=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I have a simple Go Program Which calls
syscall.RawSyscall(syscall.SYS_PTRACE, uintptr(syscall.PTRACE_TRACEME), 0, 0)
to check if a debugger is being used or not. But after a bit, I found a very strange behavior with it.
when calling using sudo.
whenever I am trying to run an external program by calling
exec.Command()

the whole code just hanging up without any error or output. I have prepared a simple Programm to recreate the problem

Download it:
example.zip

example.zip:
| run.sh
| strace.sh
| test.go

just run run.sh it will ask for sudo. Just enter the password and see the result.

What did you expect to see?

bubun@ubuntu:~/Desktop/strace-test$ ./run.sh 
[sudo] password for bubun: 
Not Being Traced
Executing a command in Go

What did you see instead?

bubun@ubuntu:~/Desktop/strace-test$ ./run.sh 
[sudo] password for bubun: 
Not Being Traced
<< === The Executable Hunging Up Without Any Output or error
@bubundas17
Copy link
Author

Well, I have compiled a c++ code to check if this behavior is also present in c++.
And yes, the same exact thing is happening with c++ as well.
It doesn't seem like a go specific issue.

But I am still curious and wanna find out why.

@golang golang locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants