Skip to content

Commit 6eeeb08

Browse files
isilencegregkh
authored andcommitted
io_uring: don't post tag CQEs on file/buffer registration failure
Commit ab6005f upstream. Buffer / file table registration is all or nothing, if it fails all resources we might have partially registered are dropped and the table is killed. If that happens, it doesn't make sense to post any rsrc tag CQEs. That would be confusing to the application, which should not need to handle that case. Cc: stable@vger.kernel.org Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Fixes: 7029acd ("io_uring/rsrc: get rid of per-ring io_rsrc_node list") Link: https://lore.kernel.org/r/c514446a8dcb0197cddd5d4ba8f6511da081cf1f.1743777957.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4c08407 commit 6eeeb08

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

io_uring/rsrc.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ struct io_rsrc_node *io_rsrc_node_alloc(int type)
130130
return node;
131131
}
132132

133+
static void io_clear_table_tags(struct io_rsrc_data *data)
134+
{
135+
int i;
136+
137+
for (i = 0; i < data->nr; i++) {
138+
struct io_rsrc_node *node = data->nodes[i];
139+
140+
if (node)
141+
node->tag = 0;
142+
}
143+
}
144+
133145
__cold void io_rsrc_data_free(struct io_ring_ctx *ctx, struct io_rsrc_data *data)
134146
{
135147
if (!data->nr)
@@ -539,6 +551,7 @@ int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
539551
io_file_table_set_alloc_range(ctx, 0, ctx->file_table.data.nr);
540552
return 0;
541553
fail:
554+
io_clear_table_tags(&ctx->file_table.data);
542555
io_sqe_files_unregister(ctx);
543556
return ret;
544557
}
@@ -855,8 +868,10 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
855868
}
856869

857870
ctx->buf_table = data;
858-
if (ret)
871+
if (ret) {
872+
io_clear_table_tags(&ctx->buf_table);
859873
io_sqe_buffers_unregister(ctx);
874+
}
860875
return ret;
861876
}
862877

0 commit comments

Comments
 (0)