Skip to content

Commit d11d31f

Browse files
committed
io_uring: fix races with buffer table unregister
Fixed buffer table quiesce might unlock ->uring_lock, potentially letting new requests to be submitted, don't allow those requests to use the table as they will race with unregistration. Reported-and-tested-by: van fantasy <[email protected]> Fixes: bd54b6f ("io_uring: implement fixed buffers registration similar to fixed files") Signed-off-by: Pavel Begunkov <[email protected]>
1 parent b0380bf commit d11d31f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/io_uring.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10680,12 +10680,19 @@ static void __io_sqe_buffers_unregister(struct io_ring_ctx *ctx)
1068010680

1068110681
static int io_sqe_buffers_unregister(struct io_ring_ctx *ctx)
1068210682
{
10683+
unsigned nr = ctx->nr_user_bufs;
1068310684
int ret;
1068410685

1068510686
if (!ctx->buf_data)
1068610687
return -ENXIO;
1068710688

10689+
/*
10690+
* Quiesce may unlock ->uring_lock, and while it's not held
10691+
* prevent new requests using the table.
10692+
*/
10693+
ctx->nr_user_bufs = 0;
1068810694
ret = io_rsrc_ref_quiesce(ctx->buf_data, ctx);
10695+
ctx->nr_user_bufs = nr;
1068910696
if (!ret)
1069010697
__io_sqe_buffers_unregister(ctx);
1069110698
return ret;

0 commit comments

Comments
 (0)