Strace -f strace / bin / ls failed with PTRACE_TRACEME EPERM (operation not allowed)

When i started

strace -f strace /bin/ls 

to find out how strace works with an error

 ptrace(PTRACE_TRACEME, 0, 0, 0) = -1 EPERM (Operation not permitted) 

even with root account.

Is there some kind of solution for this?

+5
source share
1 answer

I mention this and more helpful tips in a recent strace blog .

You need to enable support for gdb, strace, and similar tools to join processes on the system.

You can do this temporarily by running the command to set the proc parameter:

sudo bash -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'

You can save this setting between rebooting the system by changing /etc/sysctl.d/10-ptrace.conf and setting kernel.yama.ptrace_scope = 0 .

If your system does not have /etc/sysctl.d/10-ptrace.conf , you can modify /etc/sysctl.conf and set kernel.yama.ptrace_scope = 0 .

+1
source

Source: https://habr.com/ru/post/1238932/


All Articles