@@ -109,6 +109,7 @@ const struct io_op_def io_op_defs[] = {
.prep = io_prep_rw,
.issue = io_read,
.fail = io_rw_fail,
+ .can_retarget_rsrc = io_read_fixed_can_retarget_rsrc,
},
[IORING_OP_WRITE_FIXED] = {
.needs_file = 1,
@@ -1082,3 +1082,18 @@ bool io_read_can_retarget_rsrc(struct io_kiocb *req)
return true;
}
+
+bool io_read_fixed_can_retarget_rsrc(struct io_kiocb *req)
+{
+ struct io_ring_ctx *ctx = req->ctx;
+ u16 index;
+
+ if (unlikely(req->buf_index >= ctx->nr_user_bufs))
+ return false;
+
+ index = array_index_nospec(req->buf_index, ctx->nr_user_bufs);
+ if (ctx->user_bufs[index] != req->imu)
+ return false;
+
+ return io_read_can_retarget_rsrc(req);
+}
@@ -23,3 +23,4 @@ int io_writev_prep_async(struct io_kiocb *req);
void io_readv_writev_cleanup(struct io_kiocb *req);
void io_rw_fail(struct io_kiocb *req);
bool io_read_can_retarget_rsrc(struct io_kiocb *req);
+bool io_read_fixed_can_retarget_rsrc(struct io_kiocb *req);
Add can_retarget_rsrc handler for read_fixed Signed-off-by: Dylan Yudaken <dylany@meta.com> --- io_uring/opdef.c | 1 + io_uring/rw.c | 15 +++++++++++++++ io_uring/rw.h | 1 + 3 files changed, 17 insertions(+)