aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/ptrace.c
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vzapolskiy@gmail.com>2011-07-15 13:45:18 -0400
committerOleg Nesterov <oleg@redhat.com>2011-07-18 15:38:33 -0400
commitf701e5b73a1a79ea62ffd45d9e2bed4c7d5c1fd2 (patch)
tree10940ea680a1c8c69cbd9f9aa9aca23a1199aa0e /kernel/ptrace.c
parentd184d6eb1dc3c9869e25a8e422be5c55ab0db4ac (diff)
connector: add an event for monitoring process tracers
This change adds a procfs connector event, which is emitted on every successful process tracer attach or detach. If some process connects to other one, kernelspace connector reports process id and thread group id of both these involved processes. On disconnection null process id is returned. Such an event allows to create a simple automated userspace mechanism to be aware about processes connecting to others, therefore predefined process policies can be applied to them if needed. Note, a detach signal is emitted only in case, if a tracer process explicitly executes PTRACE_DETACH request. In other cases like tracee or tracer exit detach event from proc connector is not reported. Signed-off-by: Vladimir Zapolskiy <vzapolskiy@gmail.com> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Diffstat (limited to 'kernel/ptrace.c')
-rw-r--r--kernel/ptrace.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d7ccc79454f5..9de3ecfd20f9 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -23,6 +23,7 @@
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
24#include <linux/regset.h> 24#include <linux/regset.h>
25#include <linux/hw_breakpoint.h> 25#include <linux/hw_breakpoint.h>
26#include <linux/cn_proc.h>
26 27
27 28
28static int ptrace_trapping_sleep_fn(void *flags) 29static int ptrace_trapping_sleep_fn(void *flags)
@@ -305,9 +306,12 @@ unlock_tasklist:
305unlock_creds: 306unlock_creds:
306 mutex_unlock(&task->signal->cred_guard_mutex); 307 mutex_unlock(&task->signal->cred_guard_mutex);
307out: 308out:
308 if (!retval) 309 if (!retval) {
309 wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT, 310 wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT,
310 ptrace_trapping_sleep_fn, TASK_UNINTERRUPTIBLE); 311 ptrace_trapping_sleep_fn, TASK_UNINTERRUPTIBLE);
312 proc_ptrace_connector(task, PTRACE_ATTACH);
313 }
314
311 return retval; 315 return retval;
312} 316}
313 317
@@ -415,6 +419,7 @@ static int ptrace_detach(struct task_struct *child, unsigned int data)
415 } 419 }
416 write_unlock_irq(&tasklist_lock); 420 write_unlock_irq(&tasklist_lock);
417 421
422 proc_ptrace_connector(child, PTRACE_DETACH);
418 if (unlikely(dead)) 423 if (unlikely(dead))
419 release_task(child); 424 release_task(child);
420 425