Received: by 10.213.65.68 with SMTP id h4csp3901976imn; Tue, 10 Apr 2018 06:26:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JqOyhxmjGWLNoUnVGW2jZMbqO87MKURa2zFy7vuLfJmI5sCRg7C9WLdhKddThK2VDBzSC X-Received: by 2002:a17:902:9896:: with SMTP id s22-v6mr460886plp.240.1523366810069; Tue, 10 Apr 2018 06:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523366810; cv=none; d=google.com; s=arc-20160816; b=p44BBaE9b8I1zbkwioQK2PbNaWBaTvIqMcqEqqgty+FQrBWfB8fD2QTvFtsFLtU0Jh LAuuZ/SsOtsNCGEFBjKZs+/N8oGpP/WLxkGBX7e1qfUdev4zsRk9no6xKqnc9fxBwJnC 5GCwIcLcpUOVNCJmE0C33xjmxfeXVxvzX34WD0fBOlGrLRL74amRP0WxXKPkd8Dj1FGi hhGiwwz9Xp9kanJ2PeXe1HmNjJu2VCM/EwQklzckln6zTN1ii8BchcLFcyT+uXVJJRei usaW4B3kGa+M/Z7JCuVdaR5C7f4KdzeuARw2+jR+Gn9aMuTtG15QFh4nkombFRDB94gS K6VQ== 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=EZPfUT9AQRZfv851zDF9pONz3fBVKmEwor8TrA4t4RE=; b=fJKz4KKGunUYKD+oo9ro26YuRp8PZAa+R9XruYfUWJFpd7HkmVGdAi9/xro9ZLkR4Q 8LSce0t2u9fyASNuJvfJasEMxYc2qlnHSlYEZhUvust6bJQOXNbKUvMEx2Q8vSDulhyA /1sl8dnnnsZe+6SbbZKgFIuTPwbq3RvwZ6RT4Wq27izxpzmwm/h4i3g2sfhegrhT+dat 1XnWt0ARQg8SB+2JzGSpXxSllAr0HERL9mtecOZYw0m5FU5GqjqeShRFRTygN+5E8kgm 87jHApiKXpCeosN02oURujrpJNv/9sCVgitjG9sKgntRqTA3k4NqLi3XcgPqjLBRNt7a WGFQ== 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 j10-v6si2792058plt.616.2018.04.10.06.26.13; Tue, 10 Apr 2018 06:26:50 -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 S1753938AbeDJNWl (ORCPT + 99 others); Tue, 10 Apr 2018 09:22:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49638 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752859AbeDJNWj (ORCPT ); Tue, 10 Apr 2018 09:22:39 -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 665F1818B10B; Tue, 10 Apr 2018 13:22:38 +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 BA86610B2B43; Tue, 10 Apr 2018 13:22:35 +0000 (UTC) Date: Tue, 10 Apr 2018 16:22:35 +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: <20180410161905-mutt-send-email-mst@kernel.org> References: <20180410052630.11270-1-stefanha@redhat.com> <20180410052630.11270-2-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410052630.11270-2-stefanha@redhat.com> 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.8]); Tue, 10 Apr 2018 13:22:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 10 Apr 2018 13:22:38 +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 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? > --- > 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