Skip to content

Commit 92cb6e2

Browse files
old-memoriesaxboe
authored andcommitted
ublk_drv: update iod->addr for UBLK_IO_NEED_GET_DATA
If ublksrv sends UBLK_IO_NEED_GET_DATA with new allocated io buffer, we have to update iod->addr in task_work before calling io_uring_cmd_done(). Then usersapce target can handle (write)io request with the new io buffer reading from updated iod. Without this change, userspace target may touch a wrong io buffer! Signed-off-by: ZiyangZhang <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent aa0c680 commit 92cb6e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/block/ublk_drv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ static inline void __ublk_rq_task_work(struct request *req)
680680
* do the copy work.
681681
*/
682682
io->flags &= ~UBLK_IO_FLAG_NEED_GET_DATA;
683+
/* update iod->addr because ublksrv may have passed a new io buffer */
684+
ublk_get_iod(ubq, req->tag)->addr = io->addr;
685+
pr_devel("%s: update iod->addr: op %d, qid %d tag %d io_flags %x addr %llx\n",
686+
__func__, io->cmd->cmd_op, ubq->q_id, req->tag, io->flags,
687+
ublk_get_iod(ubq, req->tag)->addr);
683688
}
684689

685690
mapped_bytes = ublk_map_io(ubq, req, io);

0 commit comments

Comments
 (0)