diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 6f3b6de230bd..a67bae350416 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1153,6 +1153,13 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx struct io_rsrc_data *data; int i, ret, nbufs; + /* + * Accounting state is shared between the two rings; that only works if + * both rings are accounted towards the same counters. + */ + if (ctx->user != src_ctx->user || ctx->mm_account != src_ctx->mm_account) + return -EINVAL; + /* * Drop our own lock here. We'll setup the data we need and reference * the source buffers, then re-grab, check, and assign at the end.