Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755339Ab3J0Xsy (ORCPT ); Sun, 27 Oct 2013 19:48:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19519 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753521Ab3J0Xsv (ORCPT ); Sun, 27 Oct 2013 19:48:51 -0400 Date: Mon, 28 Oct 2013 07:48:45 +0800 From: Asias He To: "Nicholas A. Bellinger" Cc: target-devel , lf-virt , kvm-devel , linux-scsi , linux-kernel , Stefan Hajnoczi , "Michael S. Tsirkin" Subject: Re: [PATCH] vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter Message-ID: <20131027234715.GA10138@hj.localdomain> References: <1382724436-28478-1-git-send-email-nab@linux-iscsi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1382724436-28478-1-git-send-email-nab@linux-iscsi.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1986 Lines: 52 On Fri, Oct 25, 2013 at 06:07:16PM +0000, Nicholas A. Bellinger wrote: > From: Nicholas Bellinger > > 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 > Cc: Michael S. Tsirkin > Cc: Asias He > Cc: # 3.6+ > Signed-off-by: Nicholas Bellinger Reviewed-by: Asias He > --- > drivers/vhost/scsi.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > index ce5221f..e663921 100644 > --- a/drivers/vhost/scsi.c > +++ b/drivers/vhost/scsi.c > @@ -1056,7 +1056,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) > if (data_direction != DMA_NONE) { > ret = vhost_scsi_map_iov_to_sgl(cmd, > &vq->iov[data_first], data_num, > - data_direction == DMA_TO_DEVICE); > + data_direction == DMA_FROM_DEVICE); > if (unlikely(ret)) { > vq_err(vq, "Failed to map iov to sgl\n"); > goto err_free; > -- > 1.7.2.5 > -- Asias -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/