Re: sched_rr_get_interval NULL pointer OOPS

From: Peter Zijlstra
Date: Mon Jan 27 2014 - 05:54:20 EST


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 <tt.rantala@xxxxxxxxx>
Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
---
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();
--
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/