History

ublk: don't take ublk_queue in ublk_unregister_io_buf()

UBLK_IO_UNREGISTER_IO_BUF currently requires a valid q_id and tag to be passed in the ublksrv_io_cmd. However, only the addr (registered buffer index) is actually used to unregister the buffer. There is no check that the q_id and tag are for the ublk request whose buffer is registered at the given index. To prepare to allow userspace to omit the q_id and tag, check the UBLK_F_SUPPORT_ZERO_COPY flag on the ublk_device instead of the ublk_queue.

Caleb Sander Mateos committed 1 year ago

Commit 2da1e7b1 parent 2b53d4e1 file · +3 −3Browse files

Unified · Split

drivers/block/ublk_drv.c+3−3
@@ -2041,10 +2041,10 @@ static int ublk_register_io_buf(struct io_uring_cmd *cmd, · 2040 unmodified lines
20412041 }
20422042
20432043 static int ublk_unregister_io_buf(struct io_uring_cmd *cmd,
2044− const struct ublk_queue *ubq,
2044+ const struct ublk_device *ub,
20452045 unsigned int index, unsigned int issue_flags)
20462046 {
2047− if (!ublk_support_zero_copy(ubq))
2047+ if (!(ub->dev_info.flags & UBLK_F_SUPPORT_ZERO_COPY))
20482048 return -EINVAL;
20492049
20502050 return io_buffer_unregister_bvec(cmd, index, issue_flags);
@@ -2245,7 +2245,7 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, · 194 unmodified lines
22452245 case UBLK_IO_REGISTER_IO_BUF:
22462246 return ublk_register_io_buf(cmd, ubq, io, ub_cmd->addr, issue_flags);
22472247 case UBLK_IO_UNREGISTER_IO_BUF:
2248− return ublk_unregister_io_buf(cmd, ubq, ub_cmd->addr, issue_flags);
2248+ return ublk_unregister_io_buf(cmd, ub, ub_cmd->addr, issue_flags);
22492249 case UBLK_IO_COMMIT_AND_FETCH_REQ:
22502250 ret = ublk_commit_and_fetch(ubq, io, cmd, ub_cmd, issue_flags);
22512251 if (ret)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t