ptrace and kernel threads

Kevin Wilson wkevils at gmail.com
Fri Feb 22 04:38:35 EST 2013


H i all,

You will get an error when trying to call ptrace system call on kernel threads.

In code, you have the following check:
static int ptrace_attach(struct task_struct *task, long request,
                          unsigned long addr,
                          unsigned long flags)
 {
...
retval = -EPERM;
         if (unlikely(task->flags & PF_KTHREAD))
                 goto out;
...
see: http://lxr.free-electrons.com/source/kernel/ptrace.c#L233

Question: what is the reason that kernel threads cannot be traced while
userspace threads can be traced ?

rgs,
Kevin



More information about the Kernelnewbies mailing list