gdb attach permission question (ptrace_scope is read-only)

6,653

In docker you can now use the --privileged option, see https://docs.docker.com/engine/reference/commandline/exec/

docker exec --privileged -ti <container> bash

In privileged mode, gdb just works without any modifications to ptrace_scope.

Share:
6,653

Related videos on Youtube

Scott - Слава Україні
Author by

Scott - Слава Україні

Updated on September 18, 2022

Comments

  • Scott - Слава Україні
    Scott - Слава Україні over 1 year

    When using gdb to attach to the process. It shows

    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.

    As root I use echo 0 >/proc/sys/kernel/yama/ptrace_scope; then it shows:

    bash: /proc/sys/kernel/yama/ptrace_scope: Read-only file system

    How can I fix this problem? The content of /etc/sysctl.d/10-ptrace.conf is kernel.yama.ptrace_scope = 0

    • Admin
      Admin almost 9 years
      Can you try attaching that process with sudo?. And for the Read-only system you just remount your rootfs using sudo mount -o remount,rw / and then try.
    • Admin
      Admin almost 9 years
      What kind of installation are you working on? Is this some kind of virtualized environment?