From 3b688190e1d840b8357aae765911f0f00621e26f Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Thu, 17 Dec 2015 22:47:46 +0100 Subject: Fix RCU locking in sys_get_rt_task_param() sys_get_rt_task_param() is rarely used and apparently attracted some bitrot. --- litmus/litmus.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/litmus/litmus.c b/litmus/litmus.c index db5ce0e9c76e..885d75493118 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c @@ -184,21 +184,24 @@ asmlinkage long sys_get_rt_task_param(pid_t pid, struct rt_task __user * param) int retval = -EINVAL; struct task_struct *source; struct rt_task lp; + if (param == 0 || pid < 0) goto out; - read_lock(&tasklist_lock); - if (!(source = find_task_by_vpid(pid))) { + + read_lock_irq(&tasklist_lock); + rcu_read_lock(); + source = find_task_by_vpid(pid); + rcu_read_unlock(); + if (!source) { retval = -ESRCH; - goto out_unlock; + read_unlock_irq(&tasklist_lock); + goto out; } lp = source->rt_param.task_params; - read_unlock(&tasklist_lock); + read_unlock_irq(&tasklist_lock); /* Do copying outside the lock */ retval = copy_to_user(param, &lp, sizeof(lp)) ? -EFAULT : 0; - return retval; - out_unlock: - read_unlock(&tasklist_lock); out: return retval; -- cgit v1.2.2