]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.0-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Feb 2012 01:05:36 +0000 (17:05 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Feb 2012 01:05:36 +0000 (17:05 -0800)
added patches:
sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch

queue-3.0/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch [new file with mode: 0644]
queue-3.0/series

diff --git a/queue-3.0/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch b/queue-3.0/sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch
new file mode 100644 (file)
index 0000000..35039a7
--- /dev/null
@@ -0,0 +1,91 @@
+From cb297a3e433dbdcf7ad81e0564e7b804c941ff0d Mon Sep 17 00:00:00 2001
+From: Chanho Min <chanho0207@gmail.com>
+Date: Thu, 5 Jan 2012 20:00:19 +0900
+Subject: sched/rt: Fix task stack corruption under __ARCH_WANT_INTERRUPTS_ON_CTXSW
+
+From: Chanho Min <chanho0207@gmail.com>
+
+commit cb297a3e433dbdcf7ad81e0564e7b804c941ff0d upstream.
+
+This issue happens under the following conditions:
+
+ 1. preemption is off
+ 2. __ARCH_WANT_INTERRUPTS_ON_CTXSW is defined
+ 3. RT scheduling class
+ 4. SMP system
+
+Sequence is as follows:
+
+ 1.suppose current task is A. start schedule()
+ 2.task A is enqueued pushable task at the entry of schedule()
+   __schedule
+    prev = rq->curr;
+    ...
+    put_prev_task
+     put_prev_task_rt
+      enqueue_pushable_task
+ 4.pick the task B as next task.
+   next = pick_next_task(rq);
+ 3.rq->curr set to task B and context_switch is started.
+   rq->curr = next;
+ 4.At the entry of context_swtich, release this cpu's rq->lock.
+   context_switch
+    prepare_task_switch
+     prepare_lock_switch
+      raw_spin_unlock_irq(&rq->lock);
+ 5.Shortly after rq->lock is released, interrupt is occurred and start IRQ context
+ 6.try_to_wake_up() which called by ISR acquires rq->lock
+    try_to_wake_up
+     ttwu_remote
+      rq = __task_rq_lock(p)
+      ttwu_do_wakeup(rq, p, wake_flags);
+        task_woken_rt
+ 7.push_rt_task picks the task A which is enqueued before.
+   task_woken_rt
+    push_rt_tasks(rq)
+     next_task = pick_next_pushable_task(rq)
+ 8.At find_lock_lowest_rq(), If double_lock_balance() returns 0,
+   lowest_rq can be the remote rq.
+  (But,If preemption is on, double_lock_balance always return 1 and it
+   does't happen.)
+   push_rt_task
+    find_lock_lowest_rq
+     if (double_lock_balance(rq, lowest_rq))..
+ 9.find_lock_lowest_rq return the available rq. task A is migrated to
+   the remote cpu/rq.
+   push_rt_task
+    ...
+    deactivate_task(rq, next_task, 0);
+    set_task_cpu(next_task, lowest_rq->cpu);
+    activate_task(lowest_rq, next_task, 0);
+ 10. But, task A is on irq context at this cpu.
+     So, task A is scheduled by two cpus at the same time until restore from IRQ.
+     Task A's stack is corrupted.
+
+To fix it, don't migrate an RT task if it's still running.
+
+Signed-off-by: Chanho Min <chanho.min@lge.com>
+Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Acked-by: Steven Rostedt <rostedt@goodmis.org>
+Link: http://lkml.kernel.org/r/CAOAMb1BHA=5fm7KTewYyke6u-8DP0iUuJMpgQw54vNeXFsGpoQ@mail.gmail.com
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/sched_rt.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/kernel/sched_rt.c
++++ b/kernel/sched_rt.c
+@@ -1390,6 +1390,11 @@ static int push_rt_task(struct rq *rq)
+       if (!next_task)
+               return 0;
++#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
++       if (unlikely(task_running(rq, next_task)))
++               return 0;
++#endif
++
+ retry:
+       if (unlikely(next_task == rq->curr)) {
+               WARN_ON(1);
index 2b4d2fb89ab8ff4f09fda3b0db165638356160bd..9024a5e65b718f161964d386ec3984d09f604e3a 100644 (file)
@@ -20,3 +20,4 @@ mm-compaction-check-pfn_valid-when-entering-a-new-max_order_nr_pages-block-durin
 drm-radeon-set-desktop_height-register-to-the-framebuffer-not-mode-height.patch
 drm-nouveau-gem-fix-fence_sync-race-oops.patch
 drm-radeon-kms-disable-output-polling-when-suspended.patch
+sched-rt-fix-task-stack-corruption-under-__arch_want_interrupts_on_ctxsw.patch