diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-12-09 05:15:11 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 11:11:35 -0500 |
commit | 1a551ae715825bb2a2107a2dd68de024a1fa4e32 (patch) | |
tree | 03f29f6a37be1eea125994aee5d34b4daf804a20 | |
parent | 23f5d142519621b16cf2b378cf8adf4dcf01a616 (diff) |
sched: Use rcu in sched_get_rr_param()
read_lock(&tasklist_lock) does not protect
sys_sched_get_rr_param() against a concurrent update of the
policy or scheduler parameters as do_sched_scheduler() does not
take the tasklist_lock.
The access to task->sched_class->get_rr_interval is protected by
task_rq_lock(task).
Use rcu_read_lock() to protect find_task_by_vpid() and prevent
the task struct from going away.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20091209100706.862897167@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/sched.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 79893123325c..db5c26692dd5 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -6873,7 +6873,7 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, | |||
6873 | return -EINVAL; | 6873 | return -EINVAL; |
6874 | 6874 | ||
6875 | retval = -ESRCH; | 6875 | retval = -ESRCH; |
6876 | read_lock(&tasklist_lock); | 6876 | rcu_read_lock(); |
6877 | p = find_process_by_pid(pid); | 6877 | p = find_process_by_pid(pid); |
6878 | if (!p) | 6878 | if (!p) |
6879 | goto out_unlock; | 6879 | goto out_unlock; |
@@ -6886,13 +6886,13 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, | |||
6886 | time_slice = p->sched_class->get_rr_interval(rq, p); | 6886 | time_slice = p->sched_class->get_rr_interval(rq, p); |
6887 | task_rq_unlock(rq, &flags); | 6887 | task_rq_unlock(rq, &flags); |
6888 | 6888 | ||
6889 | read_unlock(&tasklist_lock); | 6889 | rcu_read_unlock(); |
6890 | jiffies_to_timespec(time_slice, &t); | 6890 | jiffies_to_timespec(time_slice, &t); |
6891 | retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0; | 6891 | retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0; |
6892 | return retval; | 6892 | return retval; |
6893 | 6893 | ||
6894 | out_unlock: | 6894 | out_unlock: |
6895 | read_unlock(&tasklist_lock); | 6895 | rcu_read_unlock(); |
6896 | return retval; | 6896 | return retval; |
6897 | } | 6897 | } |
6898 | 6898 | ||