Misc minor tctx fixes
Jens Axboe
maintainercover Misc minor tctx fixes
Hi,
Just two small fixes for issues introduced in this merge window.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH 1/2 io_uring/tctx: check for setup tctx->io_wq before teardown
As with the idling code before it, the error exit path should check for a NULL tctx->io_wq before calling io_wq_put_and_exit().
--- io_uring/tctx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
io_uring/tctx.c +2 -1
@@ -171,7 +171,8 @@ int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) }if (!current->io_uring) { err_free: -io_wq_put_and_exit (tctx->io_wq); +if (tctx->io_wq) +io_wq_put_and_exit (tctx->io_wq);percpu_counter_destroy (&tctx->inflight);kfree (tctx); }
Signature · 1 line
2.53.0
Jens Axboe
maintainerPATCH 2/2 io_uring/tctx: mark io_wq as exiting before error path teardown
In reply to Jens Axboesyzbot reports that it's hitting the below condition for exiting an io_wq context:
WARN_ON_ONCE(!test_bit(IO_WQ_BIT_EXIT, &wq->state))
in io_wq_put_and_exit(), which can be triggered with memory allocation fault injection. Ensure that the io_wq is marked as exiting to silence this warning trigger.
--- io_uring/tctx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
io_uring/tctx.c +3 -1
@@ -171,8 +171,10 @@ int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) }if (!current->io_uring) { err_free: -if (tctx->io_wq) +if (tctx->io_wq) { +io_wq_exit_start (tctx->io_wq);io_wq_put_and_exit (tctx->io_wq); + }percpu_counter_destroy (&tctx->inflight);kfree (tctx); }
Signature · 1 line
2.53.0
Re: [PATCH 1/2] io_uring/tctx: check for setup tctx->io_wq before teardown
In reply to Jens AxboeQuoted 16 lines · Jens Axboe
Quoted 1 line
As with the idling code before it, the error exit path should check for a NULL
tctx->io_wqbefore callingio_wq_put_and_exit().Fixes 7880174e1e5e ("io_uring/tctx: clean up __io_uring_add_tctx_node() error handling")Reported-by Dan Carpenter <[email protected]>Signed-off-by Jens Axboe <[email protected]>--- io_uring/tctx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)io_uring/tctx.c +0
-0
io_uring/tctx.c int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) · line 178
Quoted 9 lines
io_uring/tctx.c +2
-1@@ -171,7 +171,8 @@ int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) }if (!current->io_uring) { err_free: -io_wq_put_and_exit (tctx->io_wq); +if (tctx->io_wq) +io_wq_put_and_exit (tctx->io_wq);percpu_counter_destroy (&tctx->inflight);kfree (tctx); }
Hi Jens,
LGTM,
Thanks,
Clément
Re: [PATCH 2/2] io_uring/tctx: mark io_wq as exiting before error path teardown
In reply to Jens AxboeQuoted 23 lines · Jens Axboe
Quoted 1 line
syzbot reports that it's hitting the below condition for exiting an
io_wqcontext:
WARN_ON_ONCE(!test_bit(IO_WQ_BIT_EXIT, &wq->state))in
io_wq_put_and_exit(), which can be triggered with memory allocation fault injection. Ensure that theio_wqis marked as exiting to silence this warning trigger.Reported-by [email protected]Fixes 7880174e1e5e ("io_uring/tctx: clean up __io_uring_add_tctx_node() error handling")Signed-off-by Jens Axboe <[email protected]>--- io_uring/tctx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)io_uring/tctx.c +0
-0@@ -171,8 +171,10 @@ int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) }
io_uring/tctx.c int __io_uring_add_tctx_node(struct io_ring_ctx *ctx) · line 180
Quoted 10 lines
io_uring/tctx.c +3
-1if (!current->io_uring) { err_free: -if (tctx->io_wq) +if (tctx->io_wq) { +io_wq_exit_start (tctx->io_wq);io_wq_put_and_exit (tctx->io_wq); + }percpu_counter_destroy (&tctx->inflight);kfree (tctx); }
Hi Jens,
LGTM as well,
Thanks,
Clément