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

gdb attach fails with ptrace: Operation not permitted #2

Open
seifer08ms opened this issue Dec 9, 2016 · 5 comments
Open

gdb attach fails with ptrace: Operation not permitted #2

seifer08ms opened this issue Dec 9, 2016 · 5 comments

Comments

@seifer08ms
Copy link
Contributor

Today I ran into a weird problem. I could not attach to my own process with GDB. The process ran under user docker followed with your instruction, but GDB refused to attach. It complains like that:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.

I googled this issue and tried to modify the 10-ptrace.conf to 0, but GDB continued producing the same error messages. How to solve it ?

@vaibhav276
Copy link
Owner

@seifer08ms - Whats your setting for /proc/sys/kernel/yama/ptrace_scope?

@seifer08ms
Copy link
Contributor Author

@vaibhav276
I enter the container with docker exec -it pg_dbg /bin/bash. The content of the file is just '0'.

root@576a3bfc41ff:/# cat /proc/sys/kernel/yama/ptrace_scope
0

@vaibhav276
Copy link
Owner

Ok, just came across a new flag in docker exec called "--privileged" (https://docs.docker.com/engine/reference/commandline/exec/)

I haven't tried it myself, but you may want to give it a try. Please update if it works, or send in a pull request.

@seifer08ms
Copy link
Contributor Author

OK,I will try it. Thanks for your help !

@codehimanshu
Copy link

If running inside a container, adding --cap-add=SYS_PTRACE during docker run works

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

3 participants