• Jens Axboe's avatar
    io-wq: wait for io_wq_create() to setup necessary workers · b60fda60
    Jens Axboe authored
    We currently have a race where if setup is really slow, we can be
    calling io_wq_destroy() before we're done setting up. This will cause
    the caller to get stuck waiting for the manager to set things up, but
    the manager already exited.
    
    Fix this by doing a sync setup of the manager. This also fixes the case
    where if we failed creating workers, we'd also get stuck.
    
    In practice this race window was really small, as we already wait for
    the manager to start. Hence someone would have to call io_wq_destroy()
    after the task has started, but before it started the first loop. The
    reported test case forked tons of these, which is why it became an
    issue.
    
    Reported-by: syzbot+0f1cc17f85154f400465@syzkaller.appspotmail.com
    Fixes: 771b53d0 ("io-wq: small threadpool implementation for io_uring")
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    b60fda60
io-wq.c 25.6 KB