Uploaded image for project: 'Qt Creator'
  1. Qt Creator

ptrace: Operation not permitted when attaching gdb to application run in terminal



    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: Qt Creator 2.0.1
    • Fix Version/s: Qt Creator 3.2.0-beta1
    • Component/s: Debugger
    • Labels:
    • Environment:
      Ubuntu 10.10 amd64
      Ubuntu 12.04 64-bit
      Debian >= Wheezy
    • Commits:


      This happens on Ubuntu from version 10.10 (see https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace Protection) when debugging console project with "run in terminal" option enabled.

      Here are commented contents of /etc/sysctl.d/10-ptrace.conf :

      The PTRACE system is used for debugging. With it, a single user process
      can attach to any other dumpable process owned by the same user. In the
      case of malicious software, it is possible to use PTRACE to access
      credentials that exist in memory (re-using existing SSH connections,
      extracting GPG agent information, etc).

      A PTRACE scope of "0" is the more permissive mode. A scope of "1" limits
      PTRACE only to direct child processes (e.g. "gdb name-of-program" and
      "strace -f name-of-program" work, but gdb's "attach" and "strace -fp $PID"
      do not). The PTRACE scope is ignored when a user has CAP_SYS_PTRACE, so
      "sudo strace -fp $PID" will work as before. For more details see:

      For applications launching crash handlers that need PTRACE, exceptions can
      be registered by the debugee by declaring in the segfault handler
      specifically which process will be using PTRACE on the debugee:
      prctl(PR_SET_PTRACER, debugger_pid, 0, 0, 0);

      In general, PTRACE is not needed for the average running Ubuntu system.
      To that end, the default is to set the PTRACE scope to "1". This value
      may not be appropriate for developers or servers with only admin accounts.

      Does second to last paragraph perhaps include possible fix?

      Temporary workaround (note that this introduces security risk to your system, see Ubuntu wiki page linked above for details):
      In /etc/sysctl.d/10-ptrace.conf change value of kernel.yama.ptrace_scope to 0. This file is read at startup time so you will need to reboot to apply change.
      You can also set ptrace_scope to 0 for current session only (it will revert back to 1 after rebooting) like this:

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


          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



              orgads Orgad Shaneh
              pivo David Beer
              35 Vote for this issue
              33 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes