Skip to content

Commit

Permalink
sched: fix SCHED_FIFO tasks & FAIR_GROUP_SCHED
Browse files Browse the repository at this point in the history
Suppose that the SCHED_FIFO task does

	switch_uid(new_user);

Now, p->se.cfs_rq and p->se.parent both point into the old
user_struct->tg because sched_move_task() doesn't call set_task_cfs_rq()
for !fair_sched_class case.

Suppose that old user_struct/task_group is freed/reused, and the task
does

	sched_setscheduler(SCHED_NORMAL);

__setscheduler() sets fair_sched_class, but doesn't update
->se.cfs_rq/parent which point to the freed memory.

This means that check_preempt_wakeup() doing

		while (!is_same_group(se, pse)) {
			se = parent_entity(se);
			pse = parent_entity(pse);
		}

may OOPS in a similar way if rq->curr or p did something like above.

Perhaps we need something like the patch below, note that
__setscheduler() can't do set_task_cfs_rq().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Oleg Nesterov authored and Ingo Molnar committed Nov 15, 2007
1 parent 9778385 commit dae51f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -7087,8 +7087,10 @@ void sched_move_task(struct task_struct *tsk)

rq = task_rq_lock(tsk, &flags);

if (tsk->sched_class != &fair_sched_class)
if (tsk->sched_class != &fair_sched_class) {
set_task_cfs_rq(tsk);
goto done;
}

update_rq_clock(rq);

Expand Down

0 comments on commit dae51f5

Please sign in to comment.