Received: by 10.192.165.156 with SMTP id m28csp728944imm; Wed, 11 Apr 2018 06:27:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xbE1BLss64n4+LFLN5NrDJMAbkUNSKR/oClkh/oSxWTXWHA1uppmJobtHHaE9tO+HkEnW X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr5102455pla.328.1523453222178; Wed, 11 Apr 2018 06:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523453222; cv=none; d=google.com; s=arc-20160816; b=wAaQiVAu6JuhhtNGYsUsJdJVBdoUdCBKhbnWebQ0FebYWvvez4QCzvzNsASGIMJCCJ n8I0pSQKS85gBUXuPj7KHPSyCeFzh2Ri9rwELsTlITCFyI0g+aS8xNONkHJKKWB9RwQl i9gwy8GvRH8IFtr0bDI/hIE5Xusi/ypaIH0lAqPr7z4D/fqqQ9uH7nv8hWihF0fJnlmv IOnj0QLAcCvoDGjdqZNgcMpMfycQItAF5BlMZMtXFAanCKJyHUFwdIXhQBtnqabMv2O5 GFZe7iJ2ll+QySexTbV5AVp3vjAgWNrxZv1UO7RSZ/XldaTm8trOVYKjeg3+h9jVm2fv y+ig== 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=ayHn/3skHMbyKllQHhlGdqjomgrDepsumiiDztxSCPI=; b=Vpzo5nNcLOl5xiWD5M/dTcAqF+knQdodBvXvyeKW1iSz9Gnjihfk0Hj3Yvgm7nhADi 4yI9u7iTZIly+tf+BWDLJ+YzWcWYj2b57ABuZGXrI6Mb+4FIbrLasc4j67ykzWJXKCit FdOM81ckUY0e/HrWFEoWWwj+Cd9A/IVOjnSbF1sx5bsBO5MrQXOe6OqcW63ZGPL8nQof Ic4yaLOJkVSrL4jsnLnIkU0iuv2/j8I6HedSmt/6yLeWSZVHnwHpxFLe+oCpou4YLyv5 12olbwVZOY7tNjuY5BkTkYD2E862MXBEeTouqcXPWeEYOxSjWeTtiwulRNG/E8agbxTf 7PQg== 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 m12si745130pgd.240.2018.04.11.06.26.24; Wed, 11 Apr 2018 06:27:02 -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 S1753330AbeDKNX1 (ORCPT + 99 others); Wed, 11 Apr 2018 09:23:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47106 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753060AbeDKNXZ (ORCPT ); Wed, 11 Apr 2018 09:23:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0778B402242D; Wed, 11 Apr 2018 13:23:25 +0000 (UTC) Received: from redhat.com (ovpn-124-32.rdu2.redhat.com [10.10.124.32]) by smtp.corp.redhat.com (Postfix) with SMTP id 962FE946D5; Wed, 11 Apr 2018 13:23:22 +0000 (UTC) Date: Wed, 11 Apr 2018 16:23:22 +0300 From: "Michael S. Tsirkin" To: Stefan Hajnoczi Cc: virtualization@lists.linux-foundation.org, Linus Torvalds , jasowang@redhat.com, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] vhost: fix vhost_vq_access_ok() log check Message-ID: <20180411162317-mutt-send-email-mst@kernel.org> References: <20180411023541.15776-1-stefanha@redhat.com> <20180411023541.15776-2-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180411023541.15776-2-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 13:23:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 13:23:25 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 Wed, Apr 11, 2018 at 10:35:40AM +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 Acked-by: Michael S. Tsirkin > --- > 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 bec722e41f58..fc805b7fad9d 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