]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
io_uring/io-wq: fix `max_workers` breakage and `nr_workers` underflow
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 12 Sep 2025 00:06:09 +0000 (02:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:16:50 +0000 (11:16 +0200)
commitf757ab3db457940716a79cd5f1646aac2104b215
treef918700aafa0accfd1fc91d63c48190f7744250c
parent898aaf78480b0c707b3a0bbe8e2138f08d296b77
io_uring/io-wq: fix `max_workers` breakage and `nr_workers` underflow

commit cd4ea81be3eb94047ad023c631afd9bd6c295400 upstream.

Commit 88e6c42e40de ("io_uring/io-wq: add check free worker before
create new worker") reused the variable `do_create` for something
else, abusing it for the free worker check.

This caused the value to effectively always be `true` at the time
`nr_workers < max_workers` was checked, but it should really be
`false`.  This means the `max_workers` setting was ignored, and worse:
if the limit had already been reached, incrementing `nr_workers` was
skipped even though another worker would be created.

When later lots of workers exit, the `nr_workers` field could easily
underflow, making the problem worse because more and more workers
would be created without incrementing `nr_workers`.

The simple solution is to use a different variable for the free worker
check instead of using one variable for two different things.

Cc: stable@vger.kernel.org
Fixes: 88e6c42e40de ("io_uring/io-wq: add check free worker before create new worker")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Fengnan Chang <changfengnan@bytedance.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/io-wq.c