Skip to contentSkip to conversation

block: fix IORING_URING_CMD_REISSUE flags check in blkdev_uring_cmd

PATCH Applied Yitang Yang 3 participants 3 messages Jun 16 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix IORING_URING_CMD_REISSUE flags check in blkdev_uring_cmd

blkdev_uring_cmd() checks IORING_URING_CMD_REISSUE to determine whether this is the first issue. However, this flag lives in cmd->flags instead of issue_flags.

Coincidentally, IO_URING_F_NONBLOCK shares bit 31 with IORING_URING_CMD_REISSUE. As a result, the SQE read was never performed, bic->len remained zero, and every BLOCK_URING_CMD_DISCARD failed with -EINVAL.

Fix it by checking cmd->flags as intended.

Fixes 212ec34e4e72 ("block: only read from sqe on initial invocation of blkdev_uring_cmd")
---
 block/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/ioctl.c +1 -1
index ab2c9ed79946..3d4ea1537457 100644
@@ -951,7 +951,7 @@ int blkdev_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
 	u32 cmd_op = cmd->cmd_op;
 
 	/* Read what we need from the SQE on the first issue */
-	if (!(issue_flags & IORING_URING_CMD_REISSUE)) {
+	if (!(cmd->flags & IORING_URING_CMD_REISSUE)) {
 		const struct io_uring_sqe *sqe = cmd->sqe;
 
 		if (unlikely(sqe->ioprio || sqe->__pad1 || sqe->len ||
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Yitang Yang

blkdev_uring_cmd() checks IORING_URING_CMD_REISSUE to determine whether this is the first issue. However, this flag lives in cmd->flags instead of issue_flags.

Coincidentally, IO_URING_F_NONBLOCK shares bit 31 with IORING_URING_CMD_REISSUE. As a result, the SQE read was never performed, bic->len remained zero, and every BLOCK_URING_CMD_DISCARD failed with -EINVAL.

[...]

Applied, thanks!

[1/1] block: fix IORING_URING_CMD_REISSUE flags check in blkdev_uring_cmd

      commit: 4f919141be38ea2b1314e3a531b7b998eb64e8bc

Best regards,

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yitang Yang
Quoted 10 lines · Yitang Yang

blkdev_uring_cmd() checks IORING_URING_CMD_REISSUE to determine whether this is the first issue. However, this flag lives in cmd->flags instead of issue_flags.

Coincidentally, IO_URING_F_NONBLOCK shares bit 31 with IORING_URING_CMD_REISSUE. As a result, the SQE read was never performed, bic->len remained zero, and every BLOCK_URING_CMD_DISCARD failed with -EINVAL.

Quoted 4 lines

Fix it by checking cmd->flags as intended.

Fixes 212ec34e4e72 ("block: only read from sqe on initial invocation of blkdev_uring_cmd")
Quoted 21 lines
---
 block/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/ioctl.c +1 -2
index ab2c9ed79946..3d4ea1537457 100644
@@ -951,7 +951,7 @@ int blkdev_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
        u32 cmd_op = cmd->cmd_op;
 
        /* Read what we need from the SQE on the first issue */
-       if (!(issue_flags & IORING_URING_CMD_REISSUE)) {
+       if (!(cmd->flags & IORING_URING_CMD_REISSUE)) {
                const struct io_uring_sqe *sqe = cmd->sqe;
 
                if (unlikely(sqe->ioprio || sqe->__pad1 || sqe->len ||
--

2.43.0