Sunday, April 6, 2014

ptrace: Operation not permitted

Since Ubuntu 10.10 introduced feature ptrace_scope, which prohibits ptracing of non-child processes of non-root users. So for regular users ptracing is available from parent process only and you may see "ptrace: Operation not permitted" error while trying to attach some process to debug from gdb or trying to run debug session from your IDE, e.g. QTCreator.

You can temporary disable this security rule by calling the following command:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

It will work untill next reboot. To disable it permanently edit file /etc/sysctl.d/10-ptrace.conf and change line:

kernel.yama.ptrace_scope = 1

to:

kernel.yama.ptrace_scope = 0

To get more information about ptrace_scope feature see the following Ubuntu Wiki note:
https://wiki.ubuntu.com/Security/Features#ptrace

No comments: