summaryrefslogtreecommitdiffstats
path: root/runtime/task_finder.c
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-02-10 06:54:12 -0600
committerDavid Smith <dsmith@redhat.com>2009-02-10 06:54:12 -0600
commit7c657805a80358ce2429415af931ca1546c2c2d2 (patch)
treeb31f8ffb20d9537e1b5828ccd9bdc7c0a736def9 /runtime/task_finder.c
parent066e0c0154fd18b9fb4fa880474adb98f27bd091 (diff)
downloadsystemtap-steved-7c657805a80358ce2429415af931ca1546c2c2d2.tar.gz
systemtap-steved-7c657805a80358ce2429415af931ca1546c2c2d2.tar.xz
systemtap-steved-7c657805a80358ce2429415af931ca1546c2c2d2.zip
Ignores kernel threads (by checking for PF_KTHREAD).
2009-02-10 David Smith <dsmith@redhat.com> * task_finder.c (stap_utrace_detach): Ignores kernel threads by checking task's flags for PF_KTHREAD. (stap_utrace_detach_ops): Ditto. (__stp_utrace_attach): Ditto.
Diffstat (limited to 'runtime/task_finder.c')
-rw-r--r--runtime/task_finder.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/task_finder.c b/runtime/task_finder.c
index d9a4cedb..af606356 100644
--- a/runtime/task_finder.c
+++ b/runtime/task_finder.c
@@ -220,6 +220,14 @@ stap_utrace_detach(struct task_struct *tsk,
if (tsk == NULL || tsk->pid <= 1)
return 0;
+#ifdef PF_KTHREAD
+ // Ignore kernel threads. On systems without PF_KTHREAD,
+ // we're ok, since kernel threads won't be matched by the
+ // utrace_attach_task() call below.
+ if (tsk->flags & PF_KTHREAD)
+ return 0;
+#endif
+
// Notice we're not calling get_task_mm() here. Normally we
// avoid tasks with no mm, because those are kernel threads.
// So, why is this function different? When a thread is in
@@ -292,6 +300,14 @@ stap_utrace_detach_ops(struct utrace_engine_ops *ops)
rcu_read_lock();
do_each_thread(grp, tsk) {
+#ifdef PF_KTHREAD
+ // Ignore kernel threads. On systems without
+ // PF_KTHREAD, we're ok, since kernel threads won't be
+ // matched by the stap_utrace_detach() call.
+ if (task->flags & PF_KTHREAD)
+ continue;
+#endif
+
rc = stap_utrace_detach(tsk, ops);
if (rc != 0)
goto udo_err;
@@ -397,18 +413,26 @@ __stp_utrace_attach(struct task_struct *tsk,
enum utrace_resume_action action)
{
struct utrace_attached_engine *engine;
+#ifndef PF_KTHREAD
struct mm_struct *mm;
+#endif
int rc = 0;
// Ignore init
if (tsk == NULL || tsk->pid <= 1)
return EPERM;
+#ifdef PF_KTHREAD
+ // Ignore kernel threads
+ if (task->flags & PF_KTHREAD)
+ return EPERM;
+#else
// Ignore threads with no mm (which are kernel threads).
mm = get_task_mm(tsk);
if (! mm)
return EPERM;
mmput(mm);
+#endif
engine = utrace_attach_task(tsk, UTRACE_ATTACH_CREATE, ops, data);
if (IS_ERR(engine)) {