Commit 1a551ae715825bb2a2107a2dd68de024a1fa4e32

Authored by Thomas Gleixner
Committed by Ingo Molnar
1 parent 23f5d14251

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -6873,7 +6873,7 @@
6873 6873 return -EINVAL;
6874 6874  
6875 6875 retval = -ESRCH;
6876   - read_lock(&tasklist_lock);
  6876 + rcu_read_lock();
6877 6877 p = find_process_by_pid(pid);
6878 6878 if (!p)
6879 6879 goto out_unlock;
6880 6880  
... ... @@ -6886,13 +6886,13 @@
6886 6886 time_slice = p->sched_class->get_rr_interval(rq, p);
6887 6887 task_rq_unlock(rq, &flags);
6888 6888  
6889   - read_unlock(&tasklist_lock);
  6889 + rcu_read_unlock();
6890 6890 jiffies_to_timespec(time_slice, &t);
6891 6891 retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;
6892 6892 return retval;
6893 6893  
6894 6894 out_unlock:
6895   - read_unlock(&tasklist_lock);
  6895 + rcu_read_unlock();
6896 6896 return retval;
6897 6897 }
6898 6898