aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nvme-scsi.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2014-08-27 15:55:39 -0400
committerJens Axboe <axboe@fb.com>2014-11-04 15:17:09 -0500
commit695a4fe79ffa70023238b6b2d4c20fe1a05288fb (patch)
treec4fd6fffb45ba42442ecc7bad1113972d422b4c0 /drivers/block/nvme-scsi.c
parente179729a821c1b82375f5593533c027462e753b7 (diff)
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: Keith Busch <keith.busch@intel.com> Acked-by: Vishal Verma <vishal.l.verma@linux.intel.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/nvme-scsi.c')
-rw-r--r--drivers/block/nvme-scsi.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index dabafa6a64cb..046ae3321c5e 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -2915,6 +2915,14 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr)
2915 if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len)) 2915 if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len))
2916 return -EFAULT; 2916 return -EFAULT;
2917 2917
2918 /*
2919 * Prime the hdr with good status for scsi commands that don't require
2920 * an nvme command for translation.
2921 */
2922 retcode = nvme_trans_status_code(hdr, NVME_SC_SUCCESS);
2923 if (retcode)
2924 return retcode;
2925
2918 opcode = cmd[0]; 2926 opcode = cmd[0];
2919 2927
2920 switch (opcode) { 2928 switch (opcode) {