2020-07-29 19:13:23

by Logan Gunthorpe

[permalink] [raw]
Subject: [PATCH] nvmet-passthru: Reject commands with non-sgl flags set

Any command with a non-SGL flag set (like fuse flags) should be
rejected.

Fixes: c1fef73f793b ("nvmet: add passthru code to process commands")
Signed-off-by: Logan Gunthorpe <[email protected]>
---

Note: this patch may be squashed with the patch noted in the fixes
tag, currently in nvme-5.9.

drivers/nvme/target/passthru.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 89d91dc999a6..f69c3ac82e58 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -326,6 +326,10 @@ static u16 nvmet_setup_passthru_command(struct nvmet_req *req)

u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req)
{
+ /* Reject any commands with non-sgl flags set (ie. fused commands) */
+ if (req->cmd->common.flags & ~NVME_CMD_SGL_ALL)
+ return NVME_SC_INVALID_FIELD;
+
switch (req->cmd->common.opcode) {
case nvme_cmd_resv_register:
case nvme_cmd_resv_report:
@@ -396,6 +400,10 @@ static u16 nvmet_passthru_get_set_features(struct nvmet_req *req)

u16 nvmet_parse_passthru_admin_cmd(struct nvmet_req *req)
{
+ /* Reject any commands with non-sgl flags set (ie. fused commands) */
+ if (req->cmd->common.flags & ~NVME_CMD_SGL_ALL)
+ return NVME_SC_INVALID_FIELD;
+
/*
* Passthru all vendor specific commands
*/

base-commit: b6cec06d19d90db5dbcc50034fb33983f6259b8b
--
2.20.1


2020-08-03 19:09:51

by Chaitanya Kulkarni

[permalink] [raw]
Subject: Re: [PATCH] nvmet-passthru: Reject commands with non-sgl flags set

On 7/29/20 12:10, Logan Gunthorpe wrote:
> Any command with a non-SGL flag set (like fuse flags) should be
> rejected.
>
> Fixes: c1fef73f793b ("nvmet: add passthru code to process commands")
> Signed-off-by: Logan Gunthorpe<[email protected]>

Looks good.

Reviewed-by: Chaitanya Kulkarni <[email protected]>