Re: [syzbot] WARNING in kthread_bind_mask

From: Tejun Heo
Date: Tue Jul 11 2023 - 17:29:24 EST


Hello,

On Tue, Jul 11, 2023 at 12:01:48PM +0800, Z qiang wrote:
> Full email path here:
> https://lore.kernel.org/all/0000000000005ca92705d877448c@xxxxxxxxxx/T/
> https://syzkaller.appspot.com/bug?extid=087b7effddeec0697c66
>
>
> static void __kthread_bind_mask(struct task_struct *p, const struct
> cpumask *mask, unsigned int state)
> {
> unsigned long flags;
>
> if (!wait_task_inactive(p, state)) {
> WARN_ON(1); <--------------------------trigger warning
> return;
> }
> ....
> }
>
> Inconsistent task state trigger WARN_ON().

The usage looks correct to me. The rescuer kthread was just created
successfully and did complete(done) in kthread() and then should be either
about to sleep or already sleeping in the subsequent
schedule_preempt_disabled(). Either there's something buggy in
wait_task_inactive() or task state transition itself, or there's something
else which somehow ends up waking up the newly created task? My hunch is the
latter but it's impossible to tell from the available information.

It'd be really great if syzbot can find a repro.

Thanks.

--
tejun