Skip to content

Commit

Permalink
capabilities: Use RCU to protect task lookup in sys_capget
Browse files Browse the repository at this point in the history
cap_get_target_pid() protects the task lookup with tasklist_lock.
security_capget() is called under tasklist_lock as well but
tasklist_lock does not protect anything there. The capabilities are
protected by RCU already.

So tasklist_lock only protects the lookup and prevents the task going
away, which can be done with rcu_read_lock() as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Thomas Gleixner authored and James Morris committed Dec 9, 2009
1 parent 67fa488 commit 86fc80f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
if (pid && (pid != task_pid_vnr(current))) {
struct task_struct *target;

read_lock(&tasklist_lock);
rcu_read_lock();

target = find_task_by_vpid(pid);
if (!target)
ret = -ESRCH;
else
ret = security_capget(target, pEp, pIp, pPp);

read_unlock(&tasklist_lock);
rcu_read_unlock();
} else
ret = security_capget(current, pEp, pIp, pPp);

Expand Down

0 comments on commit 86fc80f

Please sign in to comment.