NVMe: Protect against badly formatted CQEs
Subsystems (2)
PATCH 1/1 NVMe: Protect against badly formatted CQEs
If a misbehaving device posts a CQE with a command id < depth but for one that was never allocated, the command info will have a callback function set to NULL and we don't want to try invoking that.
Signed-off-by Keith Busch <keith.busch at intel.com>
--- drivers/block/nvme-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/nvme-core.c +3 -2
@@ -247,8 +247,9 @@ static void *free_cmdid(struct nvme_queue *nvmeq, int cmdid,void *ctx;struct nvme_cmd_info *info =nvme_cmd_info (nvmeq); -if (cmdid >= nvmeq->q_depth) { - *fn = special_completion; +if (cmdid >= nvmeq->q_depth || !info[cmdid].fn) { +if (fn) + *fn = special_completion;return CMD_CTX_INVALID ; }if (fn)
Signature · 1 line
1.7.10.4