aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cred.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2010-08-02 08:29:56 +0200
committerIngo Molnar <mingo@elte.hu>2010-08-02 08:31:54 +0200
commit3772b734720e1a3f2dc1d95cfdfaa5332f4ccf01 (patch)
treea1a8cc85948c086aa12a1d8014151a7ca7c04ea8 /kernel/cred.c
parent9fc3af467d0749989518a23f7289a6f44e5cb214 (diff)
parent9fe6206f400646a2322096b56c59891d530e8d51 (diff)
downloadkernel_samsung_smdk4412-3772b734720e1a3f2dc1d95cfdfaa5332f4ccf01.zip
kernel_samsung_smdk4412-3772b734720e1a3f2dc1d95cfdfaa5332f4ccf01.tar.gz
kernel_samsung_smdk4412-3772b734720e1a3f2dc1d95cfdfaa5332f4ccf01.tar.bz2
Merge commit 'v2.6.35' into perf/core
Conflicts: tools/perf/Makefile tools/perf/util/hist.c Merge reason: Resolve the conflicts and update to latest upstream. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/cred.c')
-rw-r--r--kernel/cred.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/cred.c b/kernel/cred.c
index a2d5504..60bc8b1 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -209,6 +209,31 @@ void exit_creds(struct task_struct *tsk)
}
}
+/**
+ * get_task_cred - Get another task's objective credentials
+ * @task: The task to query
+ *
+ * Get the objective credentials of a task, pinning them so that they can't go
+ * away. Accessing a task's credentials directly is not permitted.
+ *
+ * The caller must also make sure task doesn't get deleted, either by holding a
+ * ref on task or by holding tasklist_lock to prevent it from being unlinked.
+ */
+const struct cred *get_task_cred(struct task_struct *task)
+{
+ const struct cred *cred;
+
+ rcu_read_lock();
+
+ do {
+ cred = __task_cred((task));
+ BUG_ON(!cred);
+ } while (!atomic_inc_not_zero(&((struct cred *)cred)->usage));
+
+ rcu_read_unlock();
+ return cred;
+}
+
/*
* Allocate blank credentials, such that the credentials can be filled in at a
* later date without risk of ENOMEM.