@@ -517,6 +517,21 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
return done ? done : err;
}
+int io_install_buffer(struct io_ring_ctx *ctx,
+ struct io_mapped_ubuf *imu,
+ unsigned i)
+{
+ if (unlikely(i >= ctx->nr_user_bufs))
+ return -EFAULT;
+
+ i = array_index_nospec(i, ctx->nr_user_bufs);
+ if (unlikely(ctx->user_bufs[i] != ctx->dummy_ubuf))
+ return -EINVAL;
+
+ ctx->user_bufs[i] = imu;
+ return 0;
+}
+
static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned type,
struct io_uring_rsrc_update2 *up,
unsigned nr_args)
@@ -75,6 +75,9 @@ void __io_sqe_buffers_unregister(struct io_ring_ctx *ctx);
int io_sqe_buffers_unregister(struct io_ring_ctx *ctx);
int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
unsigned int nr_args, u64 __user *tags);
+int io_install_buffer(struct io_ring_ctx *ctx, struct io_mapped_ubuf *imu,
+ unsigned i);
+
void __io_sqe_files_unregister(struct io_ring_ctx *ctx);
int io_sqe_files_unregister(struct io_ring_ctx *ctx);
int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
Add a new helper called io_install_buffer(), which will be used later for operations willing to install buffers into the registered buffer table. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- io_uring/rsrc.c | 15 +++++++++++++++ io_uring/rsrc.h | 3 +++ 2 files changed, 18 insertions(+)