io-wq: remove spurious bit clear on task_work addition
authorJens Axboe <axboe@kernel.dk>
Mon, 6 Dec 2021 17:49:04 +0000 (10:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Dec 2021 08:32:51 +0000 (09:32 +0100)
commit e47498afeca9a0c6d07eeeacc46d563555a3f677 upstream.

There's a small race here where the task_work could finish and drop
the worker itself, so that by the time that task_work_add() returns
with a successful addition we've already put the worker.

The worker callbacks clear this bit themselves, so we don't actually
need to manually clear it in the caller. Get rid of it.

Reported-by: syzbot+b60c982cb0efc5e05a47@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io-wq.c

index e8f77903d7757d97ce4a41a3700d5d99781da168..0d27c2a7d2cdd0321335e91b7c80e2c8589c7d39 100644 (file)
@@ -359,10 +359,8 @@ static bool io_queue_worker_create(struct io_worker *worker,
 
        init_task_work(&worker->create_work, func);
        worker->create_index = acct->index;
-       if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) {
-               clear_bit_unlock(0, &worker->create_state);
+       if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL))
                return true;
-       }
        clear_bit_unlock(0, &worker->create_state);
 fail_release:
        io_worker_release(worker);