]> www.infradead.org Git - users/hch/misc.git/commitdiff
nvme: use helpers to access io_uring cmd space
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 18 Oct 2024 16:16:37 +0000 (17:16 +0100)
committerKeith Busch <kbusch@kernel.org>
Tue, 22 Oct 2024 14:28:36 +0000 (07:28 -0700)
Command implementations shouldn't be directly looking into io_uring_cmd
to carve free space. Use an io_uring helper, which will also do build
time size sanitisation.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/ioctl.c

index b9b79ccfabf8ab17f7fe4370779d4e2f79822802..d5223bb6e38d04dcf65775a87f08c2aced4cde21 100644 (file)
@@ -402,7 +402,7 @@ struct nvme_uring_cmd_pdu {
 static inline struct nvme_uring_cmd_pdu *nvme_uring_cmd_pdu(
                struct io_uring_cmd *ioucmd)
 {
-       return (struct nvme_uring_cmd_pdu *)&ioucmd->pdu;
+       return io_uring_cmd_to_pdu(ioucmd, struct nvme_uring_cmd_pdu);
 }
 
 static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd,
@@ -632,8 +632,6 @@ static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
        struct nvme_ctrl *ctrl = ns->ctrl;
        int ret;
 
-       BUILD_BUG_ON(sizeof(struct nvme_uring_cmd_pdu) > sizeof(ioucmd->pdu));
-
        ret = nvme_uring_cmd_checks(issue_flags);
        if (ret)
                return ret;