Skip to content

Commit 31a5978

Browse files
min15.likeithbusch
authored andcommitted
nvme: fix miss command type check
In the function nvme_passthru_end(), only the value of the command opcode is checked, without checking the command type (IO command or Admin command). When we send a Dataset Management command (The opcode of the Dataset Management command is the same as the Set Feature command), kernel thinks it is a set feature command, then sets the controller's keep alive interval, and calls nvme_keep_alive_work(). Signed-off-by: min15.li <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent a3a9d63 commit 31a5978

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
11151115
}
11161116
EXPORT_SYMBOL_NS_GPL(nvme_passthru_start, NVME_TARGET_PASSTHRU);
11171117

1118-
void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
1118+
void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
11191119
struct nvme_command *cmd, int status)
11201120
{
11211121
if (effects & NVME_CMD_EFFECTS_CSE_MASK) {
@@ -1132,6 +1132,8 @@ void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
11321132
nvme_queue_scan(ctrl);
11331133
flush_work(&ctrl->scan_work);
11341134
}
1135+
if (ns)
1136+
return;
11351137

11361138
switch (cmd->common.opcode) {
11371139
case nvme_admin_set_features:

drivers/nvme/host/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
254254
blk_mq_free_request(req);
255255

256256
if (effects)
257-
nvme_passthru_end(ctrl, effects, cmd, ret);
257+
nvme_passthru_end(ctrl, ns, effects, cmd, ret);
258258

259259
return ret;
260260
}

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
10771077
u8 opcode);
10781078
u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode);
10791079
int nvme_execute_rq(struct request *rq, bool at_head);
1080-
void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
1080+
void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
10811081
struct nvme_command *cmd, int status);
10821082
struct nvme_ctrl *nvme_ctrl_from_file(struct file *file);
10831083
struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);

drivers/nvme/target/passthru.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
243243
blk_mq_free_request(rq);
244244

245245
if (effects)
246-
nvme_passthru_end(ctrl, effects, req->cmd, status);
246+
nvme_passthru_end(ctrl, ns, effects, req->cmd, status);
247247
}
248248

249249
static enum rq_end_io_ret nvmet_passthru_req_done(struct request *rq,

0 commit comments

Comments
 (0)