io_uring: finish waiting before flushing overflow entries
authorJens Axboe <axboe@kernel.dk>
Wed, 21 Dec 2022 14:05:09 +0000 (07:05 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 21 Dec 2022 15:43:53 +0000 (08:43 -0700)
commit52ea806ad983490b3132a9e526e11a10dc2fd10c
treec1a8029e933faa2d1091d18786b466a63e061b28
parent5ad70eb27d2b87ec722fedd23638354be37ea0b0
io_uring: finish waiting before flushing overflow entries

If we have overflow entries being generated after we've done the
initial flush in io_cqring_wait(), then we could be flushing them in the
main wait loop as well. If that's done after having added ourselves
to the cq_wait waitqueue, then the task state can be != TASK_RUNNING
when we enter the overflow flush.

Check for the need to overflow flush, and finish our wait cycle first
if we have to do so.

Reported-and-tested-by: syzbot+cf6ea1d6bb30a4ce10b2@syzkaller.appspotmail.com
Link: https://lore.kernel.org/io-uring/000000000000cb143a05f04eee15@google.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c