+14
−7
+32
−2
Loading
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: 152e11f6 ("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