aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Coddington <bcodding@redhat.com>2016-06-06 18:07:59 -0400
committerMichael S. Tsirkin <mst@redhat.com>2016-08-23 10:16:57 -0400
commita77ec83a57890240c546df00ca5df1cdeedb1cc3 (patch)
treefe37edca9e7e94664939a1e6ad3605501d55ccf7
parentfa8410b355251fd30341662a40ac6b22d3e38468 (diff)
vhost/scsi: fix reuse of &vq->iov[out] in response
The address of the iovec &vq->iov[out] is not guaranteed to contain the scsi command's response iovec throughout the lifetime of the command. Rather, it is more likely to contain an iovec from an immediately following command after looping back around to vhost_get_vq_desc(). Pass along the iovec entirely instead. Fixes: 79c14141a487 ("vhost/scsi: Convert completion path to use copy_to_iter") Cc: stable@vger.kernel.org Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/vhost/scsi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 9d6320e8ff3e..6e29d053843d 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -88,7 +88,7 @@ struct vhost_scsi_cmd {
88 struct scatterlist *tvc_prot_sgl; 88 struct scatterlist *tvc_prot_sgl;
89 struct page **tvc_upages; 89 struct page **tvc_upages;
90 /* Pointer to response header iovec */ 90 /* Pointer to response header iovec */
91 struct iovec *tvc_resp_iov; 91 struct iovec tvc_resp_iov;
92 /* Pointer to vhost_scsi for our device */ 92 /* Pointer to vhost_scsi for our device */
93 struct vhost_scsi *tvc_vhost; 93 struct vhost_scsi *tvc_vhost;
94 /* Pointer to vhost_virtqueue for the cmd */ 94 /* Pointer to vhost_virtqueue for the cmd */
@@ -547,7 +547,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
547 memcpy(v_rsp.sense, cmd->tvc_sense_buf, 547 memcpy(v_rsp.sense, cmd->tvc_sense_buf,
548 se_cmd->scsi_sense_length); 548 se_cmd->scsi_sense_length);
549 549
550 iov_iter_init(&iov_iter, READ, cmd->tvc_resp_iov, 550 iov_iter_init(&iov_iter, READ, &cmd->tvc_resp_iov,
551 cmd->tvc_in_iovs, sizeof(v_rsp)); 551 cmd->tvc_in_iovs, sizeof(v_rsp));
552 ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); 552 ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter);
553 if (likely(ret == sizeof(v_rsp))) { 553 if (likely(ret == sizeof(v_rsp))) {
@@ -1044,7 +1044,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
1044 } 1044 }
1045 cmd->tvc_vhost = vs; 1045 cmd->tvc_vhost = vs;
1046 cmd->tvc_vq = vq; 1046 cmd->tvc_vq = vq;
1047 cmd->tvc_resp_iov = &vq->iov[out]; 1047 cmd->tvc_resp_iov = vq->iov[out];
1048 cmd->tvc_in_iovs = in; 1048 cmd->tvc_in_iovs = in;
1049 1049
1050 pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", 1050 pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n",