提交 695a4fe7 编写于 作者: K Keith Busch 提交者: Jens Axboe

NVMe: Fix SG_IO status values

We've only been setting the sg_io_hdr status values on SCSI commands
that require an nvme command to complete the translation. The fields
in the struct are output parameters, so we have to set them, otherwise
user space will see whatever was in memory from before. In the case of
compat SG_IO, this would reveal kernel memory. This fixes the issue by
initializing the sg_io_hdr with successful status.
Signed-off-by: NKeith Busch <keith.busch@intel.com>
Acked-by: NVishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: NMatthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 e179729a
...@@ -2915,6 +2915,14 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr) ...@@ -2915,6 +2915,14 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr)
if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len)) if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len))
return -EFAULT; return -EFAULT;
/*
* Prime the hdr with good status for scsi commands that don't require
* an nvme command for translation.
*/
retcode = nvme_trans_status_code(hdr, NVME_SC_SUCCESS);
if (retcode)
return retcode;
opcode = cmd[0]; opcode = cmd[0];
switch (opcode) { switch (opcode) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册