Re: sched_rr_get_interval NULL pointer OOPS

Peter Zijlstra <[email protected]>
Newsgroups org.kernel.vger.trinity,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Fri, Jan 24, 2014 at 10:55:56PM +0200, Tommi Rantala wrote:
> Hello,
> 
> Trinity triggered the following bug in two separate qemu virtual
> machines after fuzzing v3.13-3995-g0dc3fd0 for a day or two. I have
> not been running Trinity in a while, so no idea if this is a
> regression or not.
> 
> If I'm reading this right, it's oopsing in kernel/sched/core.c:
> 
> SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
>     struct timespec __user *, interval)
> {
> ...
>     rq = task_rq_lock(p, &flags);
>     time_slice = p->sched_class->get_rr_interval(rq, p);   <==
>     task_rq_unlock(rq, p, &flags);
> ...


---
Subject: sched: make sched_class::get_rr_interval optional

Not all classes implement (or can implement) a useful get_rr_interval()
function, default to a 0 time-slice for them.

Reported-by: Tommi Rantala <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
---
Index: linux-2.6/kernel/sched/core.c
===================================================================
--- linux-2.6.orig/kernel/sched/core.c
+++ linux-2.6/kernel/sched/core.c
@@ -4324,7 +4324,9 @@ SYSCALL_DEFINE2(sched_rr_get_interval, p
 		goto out_unlock;
 
 	rq = task_rq_lock(p, &flags);
-	time_slice = p->sched_class->get_rr_interval(rq, p);
+	time_slice = 0;
+	if (p->sched_class->get_rr_interval)
+		time_slice = p->sched_class->get_rr_interval(rq, p);
 	task_rq_unlock(rq, p, &flags);
 
 	rcu_read_unlock();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.