diff mbox series

[for-next] nvme: use helpers to access io_uring cmd space

Message ID c274d35f441c649f0b725c70f681ec63774fce3b.1729265044.git.asml.silence@gmail.com (mailing list archive)
State New, archived
Headers show
Series [for-next] nvme: use helpers to access io_uring cmd space | expand

Commit Message

Pavel Begunkov Oct. 18, 2024, 4:16 p.m. UTC
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>
---
 drivers/nvme/host/ioctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Jens Axboe Oct. 18, 2024, 6:37 p.m. UTC | #1
On 10/18/24 10:16 AM, Pavel Begunkov wrote:
> 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.

Reviewed-by: Jens Axboe <axboe@kernel.dk>
Anuj gupta Oct. 18, 2024, 6:43 p.m. UTC | #2
Looks good:
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Chaitanya Kulkarni Oct. 19, 2024, 12:44 a.m. UTC | #3
+ (linux-nvme)

On 10/18/24 09:16, Pavel Begunkov wrote:
> 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>
> ---
>   drivers/nvme/host/ioctl.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 1d769c842fbf..6f351da7f049 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -404,7 +404,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,
> @@ -634,8 +634,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;

Indeed from io_uring_cmd_private_sz_check(), Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Kanchan Joshi Oct. 21, 2024, 3:53 a.m. UTC | #4
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Keith Busch Oct. 21, 2024, 3:16 p.m. UTC | #5
On Fri, Oct 18, 2024 at 05:16:37PM +0100, Pavel Begunkov wrote:
> 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.

Thanks, applied to nvme-6.13.
Pavel Begunkov Oct. 21, 2024, 4:04 p.m. UTC | #6
On 10/19/24 01:44, Chaitanya Kulkarni wrote:
> + (linux-nvme)

My bad, lost CC nvme. Thanks for review


> On 10/18/24 09:16, Pavel Begunkov wrote:
>> 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>
diff mbox series

Patch

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 1d769c842fbf..6f351da7f049 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -404,7 +404,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,
@@ -634,8 +634,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;