From 7ebcd64889413dd8c65b9245d2f764ba89e07be5 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Fri, 3 Sep 2021 16:52:28 +0800 Subject: [PATCH] nvmf/vfio-user: check ADMIN command PSDT field Previously we used assert for this check. Fix #2141. Change-Id: Ieaf8e34721a5b65e6d7790d56587239e2e6d75f4 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9383 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- lib/nvmf/vfio_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 1344d781a..b22b241e3 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -2613,7 +2613,10 @@ map_admin_cmd_req(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_request * } /* ADMIN command will not use SGL */ - assert(req->cmd->nvme_cmd.psdt == 0); + if (req->cmd->nvme_cmd.psdt != 0) { + return -EINVAL; + } + iovcnt = vfio_user_map_cmd(ctrlr, req, req->iov, len); if (iovcnt < 0) { SPDK_ERRLOG("%s: map Admin Opc %x failed\n",