mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 2/2] sched: Protect sched_rr_get_param access to task->sched_class
@ 2009-12-08 20:24 Thomas Gleixner
  2009-12-09  8:00 ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Gleixner @ 2009-12-08 20:24 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra

[-- Attachment #1: sched-fix-sched-get-rr-param-race.patch --]
[-- Type: text/plain, Size: 988 bytes --]

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@linutronix.de>
---
 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);



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-09  9:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-08 20:24 [patch 2/2] sched: Protect sched_rr_get_param access to task->sched_class Thomas Gleixner
2009-12-09  8:00 ` Peter Zijlstra
2009-12-09  8:03   ` Peter Zijlstra
2009-12-09  8:06     ` Thomas Gleixner
2009-12-09  8:32       ` [patch V2 " Thomas Gleixner
2009-12-09  8:33         ` Peter Zijlstra
2009-12-09  9:53         ` [tip:sched/urgent] sched: Protect sched_rr_get_param() " tip-bot for Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome