Skip to content

Commit 86fc80f

Browse files
KAGA-KOKOxjamesmorris
authored andcommitted
capabilities: Use RCU to protect task lookup in sys_capget
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>
1 parent 67fa488 commit 86fc80f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎kernel/capability.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
135135
if (pid && (pid != task_pid_vnr(current))) {
136136
struct task_struct *target;
137137

138-
read_lock(&tasklist_lock);
138+
rcu_read_lock();
139139

140140
target = find_task_by_vpid(pid);
141141
if (!target)
142142
ret = -ESRCH;
143143
else
144144
ret = security_capget(target, pEp, pIp, pPp);
145145

146-
read_unlock(&tasklist_lock);
146+
rcu_read_unlock();
147147
} else
148148
ret = security_capget(current, pEp, pIp, pPp);
149149

0 commit comments

Comments
 (0)