[patch 2/2] sched: Protect sched_rr_get_param access totask->sched_class

From: Thomas Gleixner
Date: Tue Dec 08 2009 - 15:24:47 EST


sched_rr_get_param calls task->sched_class->get_rr_interval(task)
without protection against a concurrent sched_setscheduler() call
which modifies task->sched_class.

Serialize the access with task_rq_lock(task);

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/sched.c | 4 ++++
1 file changed, 4 insertions(+)

Index: linux-2.6-tip/kernel/sched.c
===================================================================
--- linux-2.6-tip.orig/kernel/sched.c
+++ linux-2.6-tip/kernel/sched.c
@@ -6887,6 +6887,8 @@ SYSCALL_DEFINE2(sched_rr_get_interval, p
{
struct task_struct *p;
unsigned int time_slice;
+ unsigned long flags;
+ struct rq *rq;
int retval;
struct timespec t;

@@ -6903,7 +6905,9 @@ SYSCALL_DEFINE2(sched_rr_get_interval, p
if (retval)
goto out_unlock;

+ rq = task_rq_lock(p, &flags);
time_slice = p->sched_class->get_rr_interval(p);
+ task_rq_unlock(rq, &flags);

read_unlock(&tasklist_lock);
jiffies_to_timespec(time_slice, &t);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/