Patchwork [6/6] Yama: use thread group leader when creating match

login
register
mail settings
Submitter Paolo Pisati
Date Nov. 24, 2011, 10:07 a.m.
Message ID <1322129246-5397-7-git-send-email-paolo.pisati@canonical.com>
Download mbox | patch
Permalink /patch/127467/
State New
Headers show

Comments

Paolo Pisati - Nov. 24, 2011, 10:07 a.m.
From: Kees Cook <kees.cook@canonical.com>

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>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
(cherry picked from commit ad0ff93928b5b690054ba8a8fa9cd37464733122)

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

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 security/yama/yama_lsm.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Patch

diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index f3e7d7f..be177ca 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -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;
 	}