Commit b55945c
Peter Zijlstra
sched: Fix pick_next_task_fair() vs try_to_wake_up() race
Syzkaller robot reported KCSAN tripping over the
ASSERT_EXCLUSIVE_WRITER(p->on_rq) in __block_task().
The report noted that both pick_next_task_fair() and try_to_wake_up()
were concurrently trying to write to the same p->on_rq, violating the
assertion -- even though both paths hold rq->__lock.
The logical consequence is that both code paths end up holding a
different rq->__lock. And looking through ttwu(), this is possible
when the __block_task() 'p->on_rq = 0' store is visible to the ttwu()
'p->on_rq' load, which then assumes the task is not queued and
continues to migrate it.
Rearrange things such that __block_task() releases @p with the store
and no code thereafter will use @p again.
Fixes: 152e11f ("sched/fair: Implement delayed dequeue")
Reported-by: [email protected]
Reported-by: Kent Overstreet <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Tested-by: Marco Elver <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]1 parent 42f7652 commit b55945c
2 files changed
+46
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5625 | 5625 | | |
5626 | 5626 | | |
5627 | 5627 | | |
5628 | | - | |
5629 | | - | |
| 5628 | + | |
| 5629 | + | |
| 5630 | + | |
5630 | 5631 | | |
5631 | 5632 | | |
5632 | 5633 | | |
| |||
7176 | 7177 | | |
7177 | 7178 | | |
7178 | 7179 | | |
7179 | | - | |
| 7180 | + | |
| 7181 | + | |
| 7182 | + | |
| 7183 | + | |
| 7184 | + | |
7180 | 7185 | | |
7181 | 7186 | | |
7182 | 7187 | | |
| |||
7193 | 7198 | | |
7194 | 7199 | | |
7195 | 7200 | | |
7196 | | - | |
7197 | | - | |
| 7201 | + | |
| 7202 | + | |
7198 | 7203 | | |
7199 | | - | |
7200 | 7204 | | |
7201 | | - | |
| 7205 | + | |
| 7206 | + | |
| 7207 | + | |
| 7208 | + | |
7202 | 7209 | | |
7203 | 7210 | | |
7204 | 7211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2769 | 2769 | | |
2770 | 2770 | | |
2771 | 2771 | | |
2772 | | - | |
2773 | | - | |
2774 | 2772 | | |
2775 | 2773 | | |
2776 | 2774 | | |
2777 | 2775 | | |
2778 | 2776 | | |
2779 | 2777 | | |
2780 | 2778 | | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
2781 | 2811 | | |
2782 | 2812 | | |
2783 | 2813 | | |
| |||
0 commit comments