aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-07-29 07:45:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-07-29 18:16:18 -0400
commit8f92054e7ca1d3a3ae50fb42d2253ac8730d9b2a (patch)
tree29d1bcf78bf04fe41c7e811f806f58d655c41f9f /include/linux
parentde09a9771a5346029f4d11e4ac886be7f9bfdd75 (diff)
CRED: Fix __task_cred()'s lockdep check and banner comment
Fix __task_cred()'s lockdep check by removing the following validation condition: lockdep_tasklist_lock_is_held() as commit_creds() does not take the tasklist_lock, and nor do most of the functions that call it, so this check is pointless and it can prevent detection of the RCU lock not being held if the tasklist_lock is held. Instead, add the following validation condition: task->exit_state >= 0 to permit the access if the target task is dead and therefore unable to change its own credentials. Fix __task_cred()'s comment to: (1) discard the bit that says that the caller must prevent the target task from being deleted. That shouldn't need saying. (2) Add a comment indicating the result of __task_cred() should not be passed directly to get_cred(), but rather than get_task_cred() should be used instead. Also put a note into the documentation to enforce this point there too. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cred.h15
-rw-r--r--include/linux/sched.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h
index ce40cbc791e2..4d2c39573f36 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -274,13 +274,18 @@ static inline void put_cred(const struct cred *_cred)
274 * @task: The task to query 274 * @task: The task to query
275 * 275 *
276 * Access the objective credentials of a task. The caller must hold the RCU 276 * Access the objective credentials of a task. The caller must hold the RCU
277 * readlock. 277 * readlock or the task must be dead and unable to change its own credentials.
278 * 278 *
279 * The caller must make sure task doesn't go away, either by holding a ref on 279 * The result of this function should not be passed directly to get_cred();
280 * task or by holding tasklist_lock to prevent it from being unlinked. 280 * rather get_task_cred() should be used instead.
281 */ 281 */
282#define __task_cred(task) \ 282#define __task_cred(task) \
283 ((const struct cred *)(rcu_dereference_check((task)->real_cred, rcu_read_lock_held() || lockdep_tasklist_lock_is_held()))) 283 ({ \
284 const struct task_struct *__t = (task); \
285 rcu_dereference_check(__t->real_cred, \
286 rcu_read_lock_held() || \
287 task_is_dead(__t)); \
288 })
284 289
285/** 290/**
286 * get_current_cred - Get the current task's subjective credentials 291 * get_current_cred - Get the current task's subjective credentials
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 747fcaedddb7..0478888c6899 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -214,6 +214,7 @@ extern char ___assert_task_state[1 - 2*!!(
214 214
215#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0) 215#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
216#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0) 216#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
217#define task_is_dead(task) ((task)->exit_state != 0)
217#define task_is_stopped_or_traced(task) \ 218#define task_is_stopped_or_traced(task) \
218 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0) 219 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
219#define task_contributes_to_load(task) \ 220#define task_contributes_to_load(task) \