Commit 6d525f97 authored by Amit Engel's avatar Amit Engel Committed by Keith Busch

nvmet: check ncqr & nsqr for set-features cmd

For set feature command when setting up NVME_FEAT_NUM_QUEUES, check
Number of I/O Completion Queues Requested (NCQR) and Number of I/O
Submission Queues Requested (NSQR) before we proceed, for invalid values
(i.e. 65535) return an appropriate NVMe invalid field status.
Signed-off-by: default avatarAmit Engel <Amit.Engel@dell.com>
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 3e98c244
...@@ -733,13 +733,22 @@ static void nvmet_execute_set_features(struct nvmet_req *req) ...@@ -733,13 +733,22 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
{ {
struct nvmet_subsys *subsys = req->sq->ctrl->subsys; struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
u16 status = 0; u16 status = 0;
u16 nsqr;
u16 ncqr;
if (!nvmet_check_data_len(req, 0)) if (!nvmet_check_data_len(req, 0))
return; return;
switch (cdw10 & 0xff) { switch (cdw10 & 0xff) {
case NVME_FEAT_NUM_QUEUES: case NVME_FEAT_NUM_QUEUES:
ncqr = (cdw11 >> 16) & 0xffff;
nsqr = cdw11 & 0xffff;
if (ncqr == 0xffff || nsqr == 0xffff) {
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break;
}
nvmet_set_result(req, nvmet_set_result(req,
(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16)); (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment