vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 25 Oct 2013 17:44:15 +0000 (10:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Nov 2013 03:08:09 +0000 (12:08 +0900)
commitf47b4a5c772de4df3c908f7d9d70ededf3a98290
treea0755f397e857ee9bc948f31f7c5aa6c82e6a629
parent853da30c8ed0b0e1f46c325ad07f8f29766a7070
vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter

commit 60a01f558af9c48b0bb31f303c479e32721add3f upstream.

This patch addresses a long-standing bug where the get_user_pages_fast()
write parameter used for setting the underlying page table entry permission
bits was incorrectly set to write=1 for data_direction=DMA_TO_DEVICE, and
passed into get_user_pages_fast() via vhost_scsi_map_iov_to_sgl().

However, this parameter is intended to signal WRITEs to pinned userspace
PTEs for the virtio-scsi DMA_FROM_DEVICE -> READ payload case, and *not*
for the virtio-scsi DMA_TO_DEVICE -> WRITE payload case.

This bug would manifest itself as random process segmentation faults on
KVM host after repeated vhost starts + stops and/or with lots of vhost
endpoints + LUNs.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Asias He <asias@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vhost/scsi.c