Received: by 10.213.65.68 with SMTP id h4csp3908924imn; Tue, 10 Apr 2018 06:32:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Nstp3sB1Pth4VRvuwfDC5FcPBLJ256yRRrOL+9+FnJiV1+xGjm3qIZj5niNhycRDX5ZMD X-Received: by 10.98.232.2 with SMTP id c2mr360947pfi.187.1523367140997; Tue, 10 Apr 2018 06:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523367140; cv=none; d=google.com; s=arc-20160816; b=O+V1b/6ITB2pVdALUxdMIymcvMDT/7pqFquuh/I7sVdWjrGsXkdzie9ijUJ9wdHiS2 30YhmtwD2hxprSTisDqxWWJte55VoNKM36uJFABEVmgTrJNM388OZ8YHUdjf3Vsytdn1 8LzI3UJklvyNlsO7RAMeEupZrnDDCZGs4z4TmgZ+p5k6P3w4cYDgoqrp9H1iP6pi+gM1 KZ599+Ufmt+BnMvrMhTDl6GSckSN6yBYYcXlhVPZnH+OPjwE+TfLohxQ+EBT9xEfTd4B zfXFV3R2OlqEjfXeBN6239cIESGexfRlHoAyV/GAFRcEq5S0vmxEVNJMcv0Nkbpa0SXT rjhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=Ue6u7tWUyVep5paVRiggMIenCZ0D5edYo8H0kfDvYD0=; b=U+U1xpNu04NI/kfn4ckC+qzDLNjAIUFd9bGOTKAqNidbsX4pOJtgyO6auTrr6WxPRO FsrTR+/fW2uCKu8kxBrQX2t082TG0biRH3JlPlpgVbXkAzQ9ZJ7aJqYqUJZHsAdfuQze 33hhX7XGztP0HSdiLZaiI5l8TSM07vmSSBwZJUXqIhN0BRn67h8Uj0jCJVSchSzjaFWM 44N6sKpMyY8KXIb7p05Tsk8Trm93UjO0krS0j5yo7fC+wflzXgPms4xXkc1beDte+C8W loQzOK921CEPWy1tXhhz0pBbT3STPlrFIZzVR1r4ERY3qg9/gYmenoGkxErQNwGRMiNk L+uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i192si1204298pgc.380.2018.04.10.06.31.43; Tue, 10 Apr 2018 06:32:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753938AbeDJN14 (ORCPT + 99 others); Tue, 10 Apr 2018 09:27:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752584AbeDJN1y (ORCPT ); Tue, 10 Apr 2018 09:27:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 489A7406F890; Tue, 10 Apr 2018 13:27:54 +0000 (UTC) Received: from redhat.com (ovpn-123-231.rdu2.redhat.com [10.10.123.231]) by smtp.corp.redhat.com (Postfix) with SMTP id CEA4B10EE6E2; Tue, 10 Apr 2018 13:27:52 +0000 (UTC) Date: Tue, 10 Apr 2018 16:27:51 +0300 From: "Michael S. Tsirkin" To: Stefan Hajnoczi Cc: virtualization@lists.linux-foundation.org, syzkaller-bugs@googlegroups.com, Linus Torvalds , kvm@vger.kernel.org, jasowang@redhat.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 1/2] vhost: fix vhost_vq_access_ok() log check Message-ID: <20180410162522-mutt-send-email-mst@kernel.org> References: <20180410052630.11270-1-stefanha@redhat.com> <20180410052630.11270-2-stefanha@redhat.com> <20180410161905-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410161905-mutt-send-email-mst@kernel.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 10 Apr 2018 13:27:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 10 Apr 2018 13:27:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 10, 2018 at 04:22:35PM +0300, Michael S. Tsirkin wrote: > On Tue, Apr 10, 2018 at 01:26:29PM +0800, Stefan Hajnoczi wrote: > > Commit d65026c6c62e7d9616c8ceb5a53b68bcdc050525 ("vhost: validate log > > when IOTLB is enabled") introduced a regression. The logic was > > originally: > > > > if (vq->iotlb) > > return 1; > > return A && B; > > > > After the patch the short-circuit logic for A was inverted: > > > > if (A || vq->iotlb) > > return A; > > return B; > > > > This patch fixes the regression by rewriting the checks in the obvious > > way, no longer returning A when vq->iotlb is non-NULL (which is hard to > > understand). > > > > Reported-by: syzbot+65a84dde0214b0387ccd@syzkaller.appspotmail.com > > Cc: Jason Wang > > Signed-off-by: Stefan Hajnoczi > > This patch only makes sense after patch 2/2 is applied. > Otherwise the logic seems reversed below. > > Can you pls squash these two? Oh, in fact the patch is ok. This just goes to show that patch 2/2 is useful. But squashing is not required. Sorry about the noise. Acked-by: Michael S. Tsirkin Fixes: d65026c6c ("vhost: validate log when IOTLB is enabled") probably stable material since patch it fixes was queued to stable? > > --- > > drivers/vhost/vhost.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > index 5320039671b7..93fd0c75b0d8 100644 > > --- a/drivers/vhost/vhost.c > > +++ b/drivers/vhost/vhost.c > > @@ -1244,10 +1244,12 @@ static int vq_log_access_ok(struct vhost_virtqueue *vq, > > /* Caller should have vq mutex and device mutex */ > > int vhost_vq_access_ok(struct vhost_virtqueue *vq) > > { > > - int ret = vq_log_access_ok(vq, vq->log_base); > > + if (!vq_log_access_ok(vq, vq->log_base)) > > + return 0; > > > > - if (ret || vq->iotlb) > > - return ret; > > + /* Access validation occurs at prefetch time with IOTLB */ > > + if (vq->iotlb) > > + return 1; > > > > return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); > > } > > -- > > 2.14.3