Yama: use thread group leader when creating match
authorKees Cook <kees.cook@canonical.com>
Tue, 8 Mar 2011 02:36:03 +0000 (18:36 -0800)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 28 Mar 2011 13:54:29 +0000 (06:54 -0700)
Like the earlier bug-fix for thread group leader when matching,
we also need to find the thread group leader for "current" when
creating the match.

BugLink: http://bugs.launchpad.net/bugs/729839

Signed-off-by: Kees Cook <kees.cook@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

security/yama/yama_lsm.c

index a1aed18..f082a55 100644 (file)
@@ -131,8 +131,12 @@ int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
                }
                else {
                        struct task_struct *tracer;
+                       struct task_struct *myself = current;
 
                        rcu_read_lock();
+                       if (!thread_group_leader(myself))
+                               myself = myself->group_leader;
+                       get_task_struct(myself);
                        tracer = find_task_by_vpid(arg2);
                        if (tracer)
                                get_task_struct(tracer);
@@ -141,9 +145,10 @@ int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
                        rcu_read_unlock();
 
                        if (tracer) {
-                               rc = yama_ptracer_add(tracer, current);
+                               rc = yama_ptracer_add(tracer, myself);
                                put_task_struct(tracer);
                        }
+                       put_task_struct(myself);
                }
                break;
        }