Skip to content

Commit 5b804b8

Browse files
joannekoonggregkh
authored andcommitted
io_uring/rsrc: fix lost entries after cloned range
commit 525916c upstream. When cloning with node replacements (IORING_REGISTER_DST_REPLACE), destination entries after the cloned range are not copied over. Add logic to copy them over to the new destination table. Fixes: c132953 ("io_uring/rsrc: allow cloning with node replacements") Cc: stable@vger.kernel.org Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c95e4c4 commit 5b804b8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

io_uring/rsrc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
12001200
if (ret)
12011201
return ret;
12021202

1203-
/* Fill entries in data from dst that won't overlap with src */
1203+
/* Copy original dst nodes from before the cloned range */
12041204
for (i = 0; i < min(arg->dst_off, ctx->buf_table.nr); i++) {
12051205
struct io_rsrc_node *src_node = ctx->buf_table.nodes[i];
12061206

@@ -1248,6 +1248,16 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
12481248
i++;
12491249
}
12501250

1251+
/* Copy original dst nodes from after the cloned range */
1252+
for (i = nbufs; i < ctx->buf_table.nr; i++) {
1253+
struct io_rsrc_node *node = ctx->buf_table.nodes[i];
1254+
1255+
if (node) {
1256+
data.nodes[i] = node;
1257+
node->refs++;
1258+
}
1259+
}
1260+
12511261
/*
12521262
* If asked for replace, put the old table. data->nodes[] holds both
12531263
* old and new nodes at this point.

0 commit comments

Comments
 (0)