Skip to content

Commit b0380bf

Browse files
committed
io_uring: fix races with file table unregister
Fixed file 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: 05f3fb3 ("io_uring: avoid ring quiesce for fixed file set unregister and update") Signed-off-by: Pavel Begunkov <[email protected]>
1 parent a7c41b4 commit b0380bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/io_uring.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9768,11 +9768,19 @@ static void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
97689768

97699769
static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
97709770
{
9771+
unsigned nr = ctx->nr_user_files;
97719772
int ret;
97729773

97739774
if (!ctx->file_data)
97749775
return -ENXIO;
9776+
9777+
/*
9778+
* Quiesce may unlock ->uring_lock, and while it's not held
9779+
* prevent new requests using the table.
9780+
*/
9781+
ctx->nr_user_files = 0;
97759782
ret = io_rsrc_ref_quiesce(ctx->file_data, ctx);
9783+
ctx->nr_user_files = nr;
97769784
if (!ret)
97779785
__io_sqe_files_unregister(ctx);
97789786
return ret;

0 commit comments

Comments
 (0)