diff options
author | Peter Zijlstra <peterz@infradead.org> | 2024-10-23 11:36:41 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2024-10-23 20:52:26 +0200 |
commit | b55945c500c5723992504aa03b362fab416863a6 (patch) | |
tree | a69e8e10526175d716041f0ce09e5e14030f6c57 /kernel/scftorture.c | |
parent | 42f7652d3eb527d03665b09edac47f85fb600924 (diff) |
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: 152e11f6df29 ("sched/fair: Implement delayed dequeue")
Reported-by: syzbot+0ec1e96c2cdf5c0e512a@syzkaller.appspotmail.com
Reported-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Marco Elver <elver@google.com>
Link: https://lkml.kernel.org/r/20241023093641.GE16066@noisy.programming.kicks-ass.net
Diffstat (limited to 'kernel/scftorture.c')
0 files changed, 0 insertions, 0 deletions