Re: [syzbot] [block?] WARNING in blk_mq_start_request

From: Chengming Zhou
Date: Wed Nov 08 2023 - 20:28:23 EST


On 2023/11/9 05:18, syzbot wrote:
> syzbot has bisected this issue to:
>
> commit d78bfa1346ab1fe04d20aa45a0678d1fc866f37c
> Author: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>
> Date: Wed Sep 13 15:16:16 2023 +0000
>
> block/null_blk: add queue_rqs() support
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=106414a8e80000
> start commit: 13d88ac54ddd Merge tag 'vfs-6.7.fsid' of git://git.kernel...
> git tree: upstream
> final oops: https://syzkaller.appspot.com/x/report.txt?x=126414a8e80000
> console output: https://syzkaller.appspot.com/x/log.txt?x=146414a8e80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=beb32a598fd79db9
> dashboard link: https://syzkaller.appspot.com/bug?extid=fcc47ba2476570cbbeb0
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1465bb08e80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13e7881f680000
>
> Reported-by: syzbot+fcc47ba2476570cbbeb0@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: d78bfa1346ab ("block/null_blk: add queue_rqs() support")
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection

CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION is enabled in the kernel config,
so null_queue_rq() will return BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE
for some requests, which have been marked as IN_FLIGHT status.

Then null_queue_rqs() put these requests in the rqlist and return back,
blk-mq will try to queue them individually once again, caused the warning
"WARN_ON_ONCE(blk_mq_rq_state(rq) != MQ_RQ_IDLE)" in blk_mq_start_request().

So handling of return value of null_queue_rq() in null_queue_rqs() is wrong,
maybe we should __blk_mq_requeue_request() for these requests, before
adding them in the rqlist?

Thanks!