mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
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 <jannh@google.com>
Fixes: 3597f2786b
("io_uring/rsrc: unify file and buffer resource tables")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
bd2703b42d
commit
c1c03ee795
|
@ -997,7 +997,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
|
|||
dst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
|
||||
if (!dst_node) {
|
||||
ret = -ENOMEM;
|
||||
goto out_put_free;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
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
|
|||
mutex_lock(&src_ctx->uring_lock);
|
||||
/* someone raced setting up buffers, dump ours */
|
||||
ret = -EBUSY;
|
||||
out_put_free:
|
||||
i = data.nr;
|
||||
while (i--) {
|
||||
if (data.nodes[i]) {
|
||||
io_buffer_unmap(src_ctx, data.nodes[i]);
|
||||
kfree(data.nodes[i]);
|
||||
}
|
||||
}
|
||||
out_unlock:
|
||||
io_rsrc_data_free(ctx, &data);
|
||||
mutex_unlock(&src_ctx->uring_lock);
|
||||
|
|
Loading…
Reference in New Issue
Block a user