Skip to content

Commit c1c03ee

Browse files
committed
io_uring/rsrc: fixup io_clone_buffers() error handling
Jann reports he can trigger a UAF if the target ring unregisters buffers before the clone operation is fully done. And additionally also an issue related to node allocation failures. Both of those stemp from the fact that the cleanup logic puts the buffers manually, rather than just relying on io_rsrc_data_free() doing it. Hence kill the manual cleanup code and just let io_rsrc_data_free() handle it, it'll put the nodes appropriately. Reported-by: Jann Horn <[email protected]> Fixes: 3597f27 ("io_uring/rsrc: unify file and buffer resource tables") Signed-off-by: Jens Axboe <[email protected]>
1 parent bd2703b commit c1c03ee

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

io_uring/rsrc.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
997997
dst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
998998
if (!dst_node) {
999999
ret = -ENOMEM;
1000-
goto out_put_free;
1000+
goto out_unlock;
10011001
}
10021002

10031003
refcount_inc(&src_node->buf->refs);
@@ -1033,14 +1033,6 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
10331033
mutex_lock(&src_ctx->uring_lock);
10341034
/* someone raced setting up buffers, dump ours */
10351035
ret = -EBUSY;
1036-
out_put_free:
1037-
i = data.nr;
1038-
while (i--) {
1039-
if (data.nodes[i]) {
1040-
io_buffer_unmap(src_ctx, data.nodes[i]);
1041-
kfree(data.nodes[i]);
1042-
}
1043-
}
10441036
out_unlock:
10451037
io_rsrc_data_free(ctx, &data);
10461038
mutex_unlock(&src_ctx->uring_lock);

0 commit comments

Comments
 (0)